define(function(){
	var resultLayer_infoHot, resultLayer_vectorInfo, themeLayer_landUsed, themeLayer_landUsedRank, themeLayer_labelTheme, resultLayer_multipleChoice,
		resultLayer_sqlselect, resultLayer_surfaceAnalysis, resultLayer_bufferAnalyse, themeLayer_dotDensity, themeLayer_reverseDistance, 
		themeLayer_kelvjin, themeLayer_discretePoints, RangeLayer, resultLayer_geometric,dragBox_geometric, resultLayer_polygonalSelection,dragBox_polygonalSelection,resultLayer_educeInfo,dragBox_educeInfo,draw_plotting, interaction_distance, interaction_area;
	var FunctionAddEvent = [];

	//ThisUpShowLayer 为最上方正在显示的图层;


	//公共函数-获取其URL
	function getUrlPingyinUrl(getnum){
		if(getnum.N.source._url)
			return getnum.N.source._url;
	}
	//导出按钮
	function _testalert(){

		_method1();

	}
	
	/*function _two(){
		//绑定-打开图层开关.layerBtn
		$('#layerBtn').click(function(){ 
			if($('#resultDiv').css('display')=='none'){
				$('#resultDiv').fadeIn(200);
				} else { 
					$('#resultDiv').fadeOut(200);
				}
			});
	}*/

    //清除
	function _clear() {
        if (dragBox_geometric) {
            map.removeInteraction(dragBox_geometric);
        } 
        if (draw) {
            map.removeInteraction(draw);
        } 
        if (interaction) {
            map.removeInteraction(interaction);
        } 
        if (vectorLayer) {
			map.removeLayer(vectorLayer);
        } 
		if(themeLayer){ 
			map.removeLayer(themeLayer); 
		} 
		if(popup) {	
			popup.setPosition(); 
		} 
        if (resultLayer) {
			var layers = map.getLayers();
			for(var i=0;i<layers.getLength();i++){
				removeLayer(layers);
			}
			source.clear();							
            map.removeLayer(resultLayer);
		}
		//测距监听
		if(interaction_distance){
			map.removeInteraction(interaction_distance);
			$('.alert').remove();
		}
		//侧面监听
		if(interaction_area){
			map.removeInteraction(interaction_area);
			$('.alert').remove();
		}
		//标绘监听
		if(draw_plotting){
			map.removeInteraction(draw_plotting);
			$('.alert').remove();
		}
		//存在来路函数，则清楚
		if (returnFunction) {
			returnFunction = "";
		}
		//框选统计
		if(resultLayer_geometric){
			var layers = map.getLayers();
			for(var i=0;i<layers.getLength();i++){
				removeLayer(layers);
			}
			source.clear(); 
            map.removeLayer(resultLayer_geometric); 
		}
		//多边形统计
		if(resultLayer_polygonalSelection){
			var layers = map.getLayers();
			for(var i=0;i<layers.getLength();i++){
				removeLayer(layers);
			}
			source.clear(); 
            map.removeLayer(resultLayer_polygonalSelection); 
		}
		//地图属性字段的导出
		if(resultLayer_educeInfo){
			var layers = map.getLayers();
			for(var i=0;i<layers.getLength();i++){
				removeLayer(layers);
			}
			source.clear(); 
            map.removeLayer(resultLayer_educeInfo); 
		}
		//信息热点
		if(resultLayer_infoHot){
			source.clear(); 
            map.removeLayer(resultLayer_infoHot); 
		}
		//矢量要素信息
		if(resultLayer_vectorInfo){
			source.clear(); 
            map.removeLayer(resultLayer_vectorInfo); 
		}
		//土地利用
		if(themeLayer_landUsed){
			source.clear(); 
            map.removeLayer(themeLayer_landUsed); 
		}
		//数值类专题
		if(themeLayer_landUsedRank){
			source.clear(); 
            map.removeLayer(themeLayer_landUsedRank); 
		}
		//标签专题
		if(themeLayer_labelTheme){
			source.clear(); 
            map.removeLayer(themeLayer_labelTheme); 
		}
		//多选统计
		if(resultLayer_multipleChoice){
			var layers = map.getLayers();
			for(var i=0;i<layers.getLength();i++){
				removeLayer(layers);
			}
			source.clear(); 
            map.removeLayer(resultLayer_multipleChoice); 
		}
		//条件查询
		if(resultLayer_sqlselect){
			source.clear(); 
            map.removeLayer(resultLayer_sqlselect); 
		}
		//表面分析
		if(resultLayer_surfaceAnalysis){
			source.clear(); 
            map.removeLayer(resultLayer_surfaceAnalysis); 
		}
		//点密度
		if(themeLayer_dotDensity){
			source.clear(); 
            map.removeLayer(themeLayer_dotDensity);  
            //map.removeLayer(RangeLayer); 
		}
		//反距离
		if(themeLayer_reverseDistance){
			source.clear(); 
            map.removeLayer(themeLayer_reverseDistance);  
            //map.removeLayer(RangeLayer); 
		}
		//克吕金
		if(themeLayer_kelvjin){
			source.clear(); 
            map.removeLayer(themeLayer_kelvjin);  
            //map.removeLayer(RangeLayer); 
		}
		//离散点差值分析
		if(themeLayer_discretePoints){
			source.clear(); 
            map.removeLayer(themeLayer_discretePoints); 
            //map.removeLayer(RangeLayer); 
		}
		//缓冲区分析选择
		if(FunctionAddEvent.bufferAnalyse){
			FunctionAddEvent.bufferAnalyse = false;
			map.un('click',getThisLayerInfo);
			source.clear(); 
            map.removeLayer(resultLayer_bufferAnalyse); 
		}
		//清除卷帘
		if(FunctionAddEvent.swipe){ 
			FunctionAddEvent.swipe = false;
			var swipeInput = document.getElementById('swipInput');
			swipeInput.style.display = "none";
			swipeInput.value = 0;
			map.render();
		} 
		//清除百度地图
		if(FunctionAddEvent.layerBaidu){
			FunctionAddEvent.layerBaidu = false;
			$('#dict').show();
			$('#baiduMap').prop("checked", false);
			$('#baiduMap').removeAttr("checked");
			map.removeLayer(layerBaidu);
			view.animate({
				center: [451343.84 , 4017036.9],
				zoom: 14
			});
		}
		//清除天地图
		if(FunctionAddEvent.layerTianDi){
			FunctionAddEvent.layerTianDi = false;
			$('#dict').show();
			$('#tiandiMap').prop("checked", false);
			$('#tiandiMap').removeAttr("checked");
			map.removeLayer(layerTianDi);
			map.removeLayer(layerTianDi2);
			view.animate({
				center: [451343.84 , 4017036.9],
				zoom: 14
			});
		}
		if($("#info-table")){
			$("#info-table").find(".table tr").not("tr:first-child").remove();
		}
		$(".vectorBox").hide();
		map.un('click', registClickEvent);
		sum = 0;
		map.removeInteraction(draw);
		source.clear();
	}

	//清除VECTOR图层	
	function removeLayer(layers){		
		layers = map.getLayers(); //读取所有图层 
		for(var i=0;i<layers.getLength();i++){ 
			for(var i=0;i<layers.getLength();i++){  			
				layers[i] = layers.item(i);  
				if(layers[i].a.layer.type=="VECTOR"){
					map.removeLayer(layers[i]);
				}
			}
		}	
	}

	//函数：获取尺寸
	function _autodivheight() { 
		//获取浏览器窗口高度
		var winHeight = 0;
		if (window.innerHeight) winHeight = window.innerHeight;
		else if ((document.body) && (document.body.clientHeight)) winHeight = document.body.clientHeight;
		//通过深入Document内部对body进行检测，获取浏览器窗口高度
		if (document.documentElement && document.documentElement.clientHeight) winHeight = document.documentElement.clientHeight;
		//DIV高度为浏览器窗口的高度
		//document.getElementById("test").style.height= winHeight +"px";
		//DIV高度为浏览器窗口高度的一半
		if (document.getElementById("content")) document.getElementById("content").style.height = (winHeight - 100) + "px";
		if (document.getElementById("left")) document.getElementById("left").style.height = (winHeight - 100) + "px";
		if (document.getElementById("right")) document.getElementById("right").style.height = (winHeight - 100) + "px";		
		if (document.getElementById("mapDiv")) document.getElementById("mapDiv").style.height = (winHeight - 132) + "px";
	}


	//二维测距
	function _distance() {
		vectorLayer = new ol.layer.Vector({
			source: source
		});
		map.addLayer(vectorLayer);
		interaction_distance = new ol.interaction.Draw({
			source: source,
			type: "LineString"
		});
		interaction_distance.on('drawstart', function (evt) {
			feature = evt.feature;
		});
		interaction_distance.on('drawend', function () {
			var distanceMeasureParam = new SuperMap.MeasureParameters(feature.getGeometry());
			new ol.supermap.MeasureService(getUrlPingyinUrl(urlPingyin[2]), {measureMode: ""}).measureDistance(distanceMeasureParam, function (serviceResult) {
				widgets.alert.showAlert(getFloat2Num(serviceResult.result.distance) + "米",true);
			});
		});
		map.addInteraction(interaction_distance);
    }


    //二维测面
    function _area() {
		vectorLayer = new ol.layer.Vector({
			source: source
		});
		map.addLayer(vectorLayer);
		interaction_area = new ol.interaction.Draw({
			source: source,
			type: "Polygon",
		});
		interaction_area.on('drawstart', function (evt) {
			feature = evt.feature;
		});
		interaction_area.on('drawend', function () {
			var areaMeasureParam = new SuperMap.MeasureParameters(feature.getGeometry());
			new ol.supermap.MeasureService(getUrlPingyinUrl(urlPingyin[2])).measureArea(areaMeasureParam, function (serviceResult) {
				widgets.alert.showAlert(getFloat2Num(serviceResult.result.area) + "平方米", true);
			});
		});
		map.addInteraction(interaction_area);
    }
    //截取小数点两位 [辅助二维测距/二维侧面]
    function getFloat2Num(flyfloat){
    	return flyfloat.toFixed(2);
    }

    
	//标绘
	function _plotting(type){
		var vector = new ol.layer.Vector({
			source: source,
			// style: new ol.style.Style({
			// 	stroke: new ol.style.Stroke({
			// 		color: 'red',
			// 		size: 2
			// 	}),
				
			// })
		});
		map.addLayer(vector);

		_clear();

		draw_plotting = new ol.interaction.Draw({
			source: source,
			type: type,
			snapTolerance: 20
		});

		map.addInteraction(draw_plotting);

		//$(".vectorBox").show();
		
	}

	function _vectorControl(){
		// Source and vector layer
		var vectorSource = new ol.source.Vector({
			projection: 'EPSG:4326',
			features: [pointFeature, circleFeature]
		});

		var style = new ol.style.Style({
			fill: new ol.style.Fill({
				color: 'rgba(255, 100, 50, 0.3)'
			}),
			stroke: new ol.style.Stroke({
				width: 2,
				color: 'rgba(255, 100, 50, 0.8)'
			}),
			image: new ol.style.Circle({
				fill: new ol.style.Fill({
					color: 'rgba(55, 200, 150, 0.5)'
				}),
				stroke: new ol.style.Stroke({
					width: 1,
					color: 'rgba(55, 200, 150, 0.8)'
				}),
				radius: 7
			}),
		});

		var vectorLayer = new ol.layer.Vector({
			source: vectorSource,
			style: style
		});
	}


	//信息热点
	function _infoHot(dataSource){
		_clear();
		var param = new SuperMap.QueryBySQLParameters({
			queryParams: {name: dataSource
			}
		});
		
        new ol.supermap.QueryService(getUrlPingyinUrl(urlPingyin[3])).queryBySQL(param, function (serviceResult) {
            var vectorSource = new ol.source.Vector({
				features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.recordsets[0].features),				
				wrapX: false	
            });
            resultLayer_infoHot = new ol.layer.Vector({
                source: vectorSource
            });            
            registClickEvent = function(e){
            	var feature = map.forEachFeatureAtPixel(e.pixel,
                    function (feature) {
                        return feature;
					}, {hitTolerance: 10});
					
            	if(feature){
            		$('#info-box').show();
            		popup = new ol.Overlay({
			            element: document.getElementById('info-box')
			        });
			        map.addOverlay(popup);
            		popup.setPosition(e.coordinate);
            		var info = feature.getProperties();
            		$('#info-box').html('<p>SmId:'+ info.SmID +'</p>'+'<p>类别:'+ info.类别 +'</p>'+'<p>负荷:'+ info.负荷 +'</p>'+'<p>图层:'+ info.LAYER +'</p>');
            	}else{
            		$('#info-box').hide();
            		//popup.setPosition();
            	}
			}
			
            map.on('click',registClickEvent);
            map.addLayer(resultLayer_infoHot);
        });
	}


	//矢量要素信息
	function _vectorInfo(){
		_clear();
		var vector = new ol.layer.Vector({
			source: source
		});
		map.addLayer(vector);
		draw = new ol.interaction.Draw({
			source: source,
			type: 'Point',
			snapTolerance: 20
		});
		map.addInteraction(draw);
		draw.on('drawend',function(){
			source.clear();
			map.removeLayer(resultLayer_vectorInfo);
			$('#info-box').hide();
			var point = new ol.geom.Point(draw.a);
			var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
	            datasetNames: ["zonggui:ZG用地规划"],
	            geometry: point,
	            spatialQueryMode: "INTERSECT"
	        });
	        new ol.supermap.FeatureService(urlData_1).getFeaturesByGeometry(geometryParam, function (serviceResult) {
	            if(serviceResult.result.featureCount < 1)
	            	return;
	            var info = serviceResult.result.features.features[0].properties;
	            if(info != 'undefined'){
	            	$('#info-box').show();
	           		popup = new ol.Overlay({
		         	   element: document.getElementById('info-box')
		        	});
		        	map.addOverlay(popup);
            		popup.setPosition([info.SMSDRIE,info.SMSDRIS]);

            		var infoStr='<p>SmId:'+ info.SMID +'</p>'+'<p>类型:'+ info.类型 +'</p>'+'<p>用地代码:'+ info.用地代 +'</p>' + '<p>用地面积:'+ info.SHAPE_AREA +'</p>'
             		var table_head='<table class="table table-bordered mt10" style="text-align:center"><tr><th>序号</th><th>文件名</th><th>文件格式</th><th>文件大小</th><th>上传时间</th><th colspan="2" style="text-align:center">操作</th></tr>';
            		var table_content;

					 var formData1 = new FormData();
 
            			formData1.append('smid',info.SMID);

     //       			//初始化文件div
       //  			$('#info-box').empty();
     //        		$('#info-box').html(infoStr+'<table class="table table-bordered mt10" style="text-align:center"><tr><th>序号</th><th>文件名</th><th>文件格式</th><th>文件大小</th><th>上传时间</th><th colspan="2" style="text-align:center">操作</th></tr></table><form id="infoLogoForm" method="post"enctype="multipart/form-data"><input type="file" name="file" id="file"/><input type="hidden" name="smid" id="smid" value='+info.SMID+'><span id="tip"></span></form><button type="button" id="upload" class="layui-btn h35 mt2 layui-btn-normal">上传</button>');
 					$('#adjunct').html('<table class="table table-bordered mt10" style="text-align:center"><tr><th>序号</th><th>文件名</th><th>文件格式</th><th>文件大小</th><th>上传时间</th><th colspan="2" style="text-align:center">操作</th></tr></table><form id="infoLogoForm" method="post"enctype="multipart/form-data"><input type="file" name="file" id="file"/><input type="hidden" name="smid" id="smid" value='+info.SMID+'><span id="tip"></span></form><button type="button" id="upload" class="layui-btn h35 mt2 layui-btn-normal">上传</button>');
            		$('#queryData').html(infoStr);
     //        		//查询文件列表div
            			
            			$.ajax({
            				url: selectFile,
							type: 'POST',
							cache: false,
							data: formData1,
							processData: false,
							contentType: false,
							dataType:"json",

							success: function(data) {
								
								if(data.status){
									$('#info-box').empty();
									table_content='';
									var orderNo=0;
									for(var f=0;f<data.info.length;f++){
										orderNo++;
										table_content+='<tr><td>'+orderNo+'</td><td>'+data.info[f].filename+'</td><td>'+data.info[f].extend+'</td><td>'+data.info[f].size+'</td><td>'+data.info[f].addtime+'</td><td><a href='+downFile+data.info[f].fileid + ' id="download" class="layui-btn h35 mt2 layui-btn-normal">下载</a></td><td><button id="button_del"  type="button" onclick='+delFile(data.info[f].smid,data.info[f].fileid)+' class="layui-btn h35 mt2 layui-btn-normal">删除</button></td></tr>'
									}
									
									$('#info-box').html(infoStr+table_head+table_content+'</table>'+'<form id="infoLogoForm" method="post"enctype="multipart/form-data"><input type="file" name="file" id="file"/><input type="hidden" name="smid" id="smid" value='+data.info[0].smid+'><span id="tip"></span></form><button type="button" id="upload" class="layui-btn h35 mt2 layui-btn-normal">上传</button>');
								}else{
									if (typeof (data.error) != 'undefined'&& data.error != '') {
										alert(data.error);
									}
								}
								
								
							}
            			});

            		//上传文件并重新加载div	
            		$('#info-box').unbind('click');
					$('#info-box').on('click','#upload', upload);

	           		function upload(){
						$.ajax({
							url: upfileURL,
							type: 'POST',
							cache: false,
							data: new FormData($('#infoLogoForm')[0]),
							processData: false,
							contentType: false,
							dataType:"json",
							success: function(data) {
								if(data.status){
									$('#info-box').empty();
									table_content='';
									var orderNo=0;
									for(var f=0;f<data.info.length;f++){
										orderNo++;
										table_content+='<tr><td>'+orderNo+'</td><td>'+data.info[f].filename+'</td><td>'+data.info[f].extend+'</td><td>'+data.info[f].size+'</td><td>'+data.info[f].addtime+'</td><td><a href='+downFile+data.info[f].fileid + ' id="download" class="layui-btn h35 mt2 layui-btn-normal">下载</a></td><td><button id="button_del"  type="button" onclick='+delFile(data.info[f].smid,data.info[f].fileid)+' class="layui-btn h35 mt2 layui-btn-normal">删除</button></td></tr>'
									}
									
									$('#info-box').html(infoStr+table_head+table_content+'</table>'+'<form id="infoLogoForm" method="post"enctype="multipart/form-data"><input type="file" name="file" id="file"/><input type="hidden" name="smid" id="smid" value='+data.info[0].smid+'><span id="tip"></span></form><button type="button" id="upload" class="layui-btn h35 mt2 layui-btn-normal">上传</button>');
									$('#tip').text('文件上传成功');
								}else{
									if (typeof (data.error) != 'undefined'&& data.error != '') {
										alert(data.error);
									}
								}
							},
							error: function(data,status,e){
								alert(status);
							}
						});

					};
	

	            }
	            var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	            resultLayer_vectorInfo = new ol.layer.Vector({
	                source: vectorSource,
	            });
	            map.addLayer(resultLayer_vectorInfo);
	        });
		});
	}

	//文件删除
	function delFile(smid1,fileid1){
		$.ajax({
			url: delFile,
			type: 'POST',
			cache: false,
			data: {"smid":smid1,"fileid1":fileid1},
			processData: false,
			contentType: false,
			dataType:"json",
			success: function(data) {
				debugger
				if (data.status) {
					alert("文件删除成功");
				}
			}
		})
	}

	//土地利用
	function _landUsed(){
		_clear();
		var style_R2,style;
		style_R2 = new SuperMap.ServerStyle({
            fillForeColor: new SuperMap.ServerColor(255, 0, 0),
            lineColor: new SuperMap.ServerColor(0, 0, 0),
            lineWidth: 0.1
		});
		style = new SuperMap.ServerStyle({
            fillForeColor: new SuperMap.ServerColor(255, 255, 255),
            lineColor: new SuperMap.ServerColor(0, 0, 0),
            lineWidth: 0.1
		});
		var themeUniqueIteme_R2 = new SuperMap.ThemeUniqueItem({
			unique: "R2",
			style: style_R2
		});
		var themeUnique = new SuperMap.ThemeUnique({
            uniqueExpression: "用地代",
            items: [themeUniqueIteme_R2],
            defaultStyle: style
		});
		var themeParameters = new SuperMap.ThemeParameters({
            datasetNames: ["ZG用地规划"],
            dataSourceNames: ["zonggui"],
            themes: [themeUnique]
		});
		new ol.supermap.ThemeService(getUrlPingyinUrl(urlPingyin[2])).getThemeInfo(themeParameters, function (serviceResult) {
			var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer_landUsed = new ol.layer.Tile({
                    source: new ol.source.TileSuperMapRest({
                        url: getUrlPingyinUrl(urlPingyin[2]),
                        noWrap: true,
                        cacheEnabled: false,
                        transparent: true,
                        layersID: result.newResourceID,
                        transparent: true
                    })
                });
                map.addLayer(themeLayer_landUsed);
            }
        });
	}	



	//数值类专题
	function _landUsedRank(type){
		_clear();
		//面积
		if(type == 'area'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 20000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(250, 204, 137),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 20000,
				end: 50000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 191, 0),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 50000,
				end: 100000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(247, 150, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 100000,
				end: 9000000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 120, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "SHAPE_AREA",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4]
			});		
		}
		//绿地率
		if(type == 'Green_space'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 0.3,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(211, 255, 250),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 0.3,
				end: 0.6,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(178, 218, 199),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 0.6,
				end: 0.8,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(58, 178, 166),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 0.8,
				end: 1,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(58, 178, 133),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "绿地率",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4]
			});
		}
		//建筑密度
		if(type == 'Building_density'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 0.1,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(250, 204, 137),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 0.1,
				end: 0.2,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 191, 0),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 0.2,
				end: 0.4,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(247, 150, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 0.4,
				end: 1,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 120, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "建筑密度",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4]
			});
		}
		//地上容积率
		if(type == 'aboveground_rate'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 1,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(251, 213, 181),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 1,
				end: 1.1,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(250, 204, 137),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 1.1,
				end: 1.5,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 191, 0),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 1.5,
				end: 1.8,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(247, 150, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_5 = new SuperMap.ThemeRangeItem({
				start: 1.8,
				end: 2,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 120, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "容积率",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4, theme_5]
			});
		}
		//建筑面积
		if(type == 'Building_area'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 2500,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(185, 230, 153),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 2500,
				end: 20000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(146, 205, 220),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 20000,
				end: 50000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(0, 200, 239),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 50000,
				end: 150000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(0, 160, 233),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_5 = new SuperMap.ThemeRangeItem({
				start: 150000,
				end: 600000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(79, 129, 189),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "建筑面积",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4, theme_5]
			});
		}
		//人口
		if(type == 'population'){
			var theme_1 = new SuperMap.ThemeRangeItem({
				start: 0,
				end: 10,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(251, 213, 181),  
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_2 = new SuperMap.ThemeRangeItem({
				start: 10,
				end: 150,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(250, 204, 137),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_3 = new SuperMap.ThemeRangeItem({
				start: 150,
				end: 500,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 191, 0),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_4 = new SuperMap.ThemeRangeItem({
				start: 500,
				end: 1500,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(247, 150, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var theme_5 = new SuperMap.ThemeRangeItem({
				start: 1500,
				end: 10000,
				style: new SuperMap.ServerStyle({
					fillForeColor: new SuperMap.ServerColor(255, 120, 70),
					lineColor: new SuperMap.ServerColor(179, 209, 193),
					lineWidth: 0.1
				})
			});
			var themeRange = new SuperMap.ThemeRange({
				rangeExpression: "人口",
				rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
				items: [theme_1, theme_2, theme_3, theme_4, theme_5]
			});
		}


        var themeParameters = new SuperMap.ThemeParameters({
            datasetNames: ["ZG用地规划"],
            dataSourceNames: ["zonggui"],
            joinItems: null,
            themes: [themeRange]
        });
        new ol.supermap.ThemeService(getUrlPingyinUrl(urlPingyin[2])).getThemeInfo(themeParameters, function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer_landUsedRank = new ol.layer.Tile({
                    source: new ol.source.TileSuperMapRest({
                        url: getUrlPingyinUrl(urlPingyin[2]),
                        noWrap: true,
                        cacheEnabled: false,
                        transparent: true,
                        layersID: result.newResourceID,
                        transparent: true
                    })
                });
                map.addLayer(themeLayer_landUsedRank);
            }
        });	

	}


	//标签专题
	function _labelTheme(){
		_clear();
		var style1, style2, style3;
        style1 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(100, 20, 50),
            sizeFixed: true,
            bold: true
        });
        style2 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(250, 0, 0),
            sizeFixed: true,
            bold: true
        });
        style3 = new SuperMap.ServerTextStyle({
            fontHeight: 4,
            foreColor: new SuperMap.ServerColor(93, 95, 255),
            sizeFixed: true,
            bold: true
		});
		
		var themeLabelItem1, themeLabelItem2, themeLabelItem3,themeLabelItem4, themeLabelItem5, themeLabelItem6;
        themeLabelItem1 = new SuperMap.ThemeLabelItem({
			start: 0,
			end: 50000,
            style: style1
        });
        themeLabelItem2 = new SuperMap.ThemeLabelItem({
            start: 50000,
            end: 300000,
            style: style2
        });
        themeLabelItem3 = new SuperMap.ThemeLabelItem({
            start: 300000,
            end: 9900000,
            style: style3
		});  
		themeLabelItem4 = new SuperMap.ThemeLabelItem({
            start: 0,
            end: 500,
            style: style1
        });
        themeLabelItem5 = new SuperMap.ThemeLabelItem({
            start: 500,
            end: 1000,
            style: style2
        });
        themeLabelItem6 = new SuperMap.ThemeLabelItem({
            start: 1000,
            end: 10000,
            style: style3
        });      
		var themeLabel = new SuperMap.ThemeLabel({
            matrixCells: [
				[new SuperMap.LabelThemeCell({
                    themeLabel: new SuperMap.ThemeLabel({
                        labelExpression: "用地代",
                        rangeExpression: "SHAPE_LENG",
                        numericPrecision: 0,
                        items: [themeLabelItem4, themeLabelItem5, themeLabelItem6]
                    })
                })],
                [new SuperMap.LabelThemeCell({
                    themeLabel: new SuperMap.ThemeLabel({
                        labelExpression: "类型",
                        rangeExpression: "SHAPE_AREA",
                        numericPrecision: 0,
                        items: [themeLabelItem1, themeLabelItem2, themeLabelItem3]
                    })
                })]
            ],
            background: new SuperMap.ThemeLabelBackground({
                backStyle: new SuperMap.ServerStyle({
                    fillForeColor: new SuperMap.ServerColor(179, 209, 193),
                    fillOpaqueRate: 60,
                    lineWidth: 0.1
                }),
                labelBackShape: "RECT"
            })
		});
		var themeParameters = new SuperMap.ThemeParameters({
            themes: [themeLabel],
            datasetNames: ["ZG用地规划"],
            dataSourceNames: ["zonggui"],
        });

        new ol.supermap.ThemeService(getUrlPingyinUrl(urlPingyin[2])).getThemeInfo(themeParameters, function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer_labelTheme = new ol.layer.Tile({
                    source: new ol.source.TileSuperMapRest({
                        url: getUrlPingyinUrl(urlPingyin[2]),
                        noWrap: true,
                        cacheEnabled: false,
                        transparent: true,
                        layersID: result.newResourceID,
                        transparent: true
                    })
                });
                map.addLayer(themeLayer_labelTheme);
            }
        });
	}


	//多选统计
	function _multipleChoice(){
		_clear();		
		var vector = new ol.layer.Vector({
			source: source
		});
		map.addLayer(vector);
		draw = new ol.interaction.Draw({
			source: source,
			type: 'Point',
		//	snapTolerance: 20
		});
		map.addInteraction(draw);
		draw.on('drawend',function(){
			var point = new ol.geom.Point(draw.a);
			var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
	            datasetNames: ["zonggui:ZG用地规划"],
	            geometry: point,
	            spatialQueryMode: "INTERSECT"
			});

	        new ol.supermap.FeatureService(urlData_2).getFeaturesByGeometry(geometryParam, function (serviceResult) {
	            if(serviceResult.result.featureCount < 1)
	            	return;
	            var info = serviceResult.result.features.features[0].properties;
	            if(info != 'undefined'){
	            	$('#info-table').show();
	           		popup = new ol.Overlay({
		         	   element: document.getElementById('info-table')
		        	});
		        	map.addOverlay(popup);
					popup.setPosition([info.SMSDRIE,info.SMSDRIS]);
	                //清除数据
					$("#info-table").find(".table tr.zongStr").remove();
					$("#info-table").find(".table tr.averageStr").remove();
					//添加行数据
					$('#info-table').find(".table").append('<tr class="result"><td></td><td>' + getFloat2Num(parseFloat(info.SHAPE_AREA)) + '</td><td>' + getFloat2Num(parseFloat(info.建筑面积)) + '</td><td>' + info.户数 + '</td><td>' + info.停车位 + '</td><td>' + info.容积率 + '</td><td>' + info.建筑密度 + '</td><td>' + info.绿地率 + '</td></tr></table>');
					//处理结果-求合
					var result = new Array(0,0,0,0,0,0,0);
					var thistableRow = $('#info-table').find('.result');
					for(var i=0; i<thistableRow.length; i++){
						result[0] += parseFloat( thistableRow.eq(i).find('td').eq(1).html() );
						result[1] += parseFloat( thistableRow.eq(i).find('td').eq(2).html() );
						result[2] += parseFloat( thistableRow.eq(i).find('td').eq(3).html() );
						result[3] += parseFloat( thistableRow.eq(i).find('td').eq(4).html() );
						result[4] += parseFloat( thistableRow.eq(i).find('td').eq(5).html() );
						result[5] += parseFloat( thistableRow.eq(i).find('td').eq(6).html() );
						result[6] += parseFloat( thistableRow.eq(i).find('td').eq(7).html() );
					}
					//处理结果-求平均
					result[4] = getFloat2Num( result[4] / thistableRow.length );
					result[5] = getFloat2Num( result[5] / thistableRow.length );
					result[6] = getFloat2Num( result[6] / thistableRow.length );
					//
					var zongStr = '<tr class="zongStr font-weight"><td>总计</td><td>'+ getFloat2Num(result[0]) +'</td><td>'+ getFloat2Num(result[1]) +'</td><td>'+ result[2] +'</td><td>'+ result[3] +'</td><td colspan="3"></td></tr>';					 
					var averageStr ='<tr class="averageStr"><td>平均值</td><td colspan="4"></td><td>'+ result[4] +'</td><td>'+ result[5] +'</td><td>'+ result[6] +'</td></tr>'
					
					$('#info-table').find(".table").append(averageStr);
					$("#info-table").find(".table tr.zongStr").remove();
					$('#info-table').find(".table").append(zongStr);
				}
				/*柱状图*/
	      	var myChart = echarts.init(document.getElementById('barGraph_table'));
	   		var option = {
            tooltip: {},
            legend: {
                data:['数据']
            },
            xAxis: {
                data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
            },
            yAxis: {},
            series: [{
                name: '数据',
                type: 'bar',
                data: [info.SHAPE_AREA,info.建筑面积,info.户数,info.停车位,info.容积率,info.建筑密度,info.绿地率]
            }]
        };
		 myChart.setOption(option);

		/*饼状图*/		 
			var myChart = echarts.init(document.getElementById('pieChart_table'));
				 option = {
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
		    },
		    series : [
		        {
		            name: '查询数据',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:[
		                {value:info.SHAPE_AREA, name:'用地面积(hm2)'},
		                {value:info.建筑面积, name:'建筑面积(万m2)'},
		                {value:info.户数, name:'居住户口(户)'},
		                {value:info.停车位, name:'停车位数(个)'},
		                {value:info.容积率, name:'容积率'},
		                {value:info.建筑密度, name:'建筑密度'},
		                {value:info.绿地率, name:'绿地率'}
		            ],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		};
	  myChart.setOption(option);
	            var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	            resultLayer_multipleChoice = new ol.layer.Vector({
	                source: vectorSource,
	            });
	            map.addLayer(resultLayer_multipleChoice);
	        });
		});
	}


	//框选统计
	function _geometric(){
		//_clear();
		//修改方法
		dragBox_geometric = new ol.interaction.DragBox({
	        condition: ol.events.condition.always
	    });
		map.addInteraction(dragBox_geometric);

		dragBox_geometric.on('boxend', function() {
			var extent = dragBox_geometric.getGeometry();
			var polygon = extent;	
			var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
	            datasetNames: ["zonggui:ZG用地规划"],
	            geometry: polygon,
	            spatialQueryMode: "INTERSECT",
	            toIndex: 2000
	        });
	        new ol.supermap.FeatureService(urlData_2).getFeaturesByGeometry(geometryParam, function (serviceResult) {
				if(serviceResult.result.featureCount < 1)
					return;
				var allInfo = serviceResult.result.features.features;
				var info = serviceResult.result.features.features[0].properties; 				
				if(info != 'undefined'){
					$('#info-table').show();
					popup = new ol.Overlay({
						element: document.getElementById('info-table') 
					});
					map.addOverlay(popup);
					popup.setPosition([info.SMSDRIE,info.SMSDRIS]); 
					//处理结果-求和
					var addhtml="";
					var SumNum = new Array(0,0,0,0,0,0,0);
					for(var i=0; i<allInfo.length; i++){
						var thisInfo = allInfo[i].properties;
						if(thisInfo.SHAPE_AREA)
							SumNum[0] += parseFloat(thisInfo.SHAPE_AREA);
						if(thisInfo.建筑面积)
							SumNum[1] += parseFloat(thisInfo.建筑面积);
						if(thisInfo.户数)
							SumNum[2] += parseFloat(thisInfo.户数);
						if(thisInfo.停车位)
							SumNum[3] += parseFloat(thisInfo.停车位);
						if(thisInfo.容积率)
							SumNum[4] += parseFloat(thisInfo.容积率);
						if(thisInfo.建筑密度)
							SumNum[5] += parseFloat(thisInfo.建筑密度);
						if(thisInfo.绿地率)
							SumNum[6] += parseFloat(thisInfo.绿地率);

						addhtml += '<tr><td></td><td>' + getFloat2Num(parseFloat(thisInfo.SHAPE_AREA)) + '</td><td>' + getFloat2Num(parseFloat(thisInfo.建筑面积)) + '</td><td>' + thisInfo.户数 + '</td><td>' + thisInfo.停车位 + '</td><td>' + thisInfo.容积率 + '</td><td>' + thisInfo.建筑密度 + '</td><td>' + thisInfo.绿地率 + '</td></tr>';

					}
					//处理结果-求平均
					SumNum[4] = getFloat2Num( SumNum[4] / allInfo.length );
					SumNum[5] = getFloat2Num( SumNum[5] / allInfo.length );
					SumNum[6] = getFloat2Num( SumNum[6] / allInfo.length );

					addhtml += '<tr class="zongStr font-weight"><td>总计</td><td>'+ getFloat2Num(SumNum[0]) +'</td><td>'+ getFloat2Num(SumNum[1]) +'</td><td>'+ SumNum[2] +'</td><td>'+ SumNum[3] +'</td><td colspan="3"></td></tr>';
					addhtml += '<tr class="zongStr font-weight"><td>平均值</td><td colspan="4"></td><td>'+ SumNum[4] +'</td><td>'+ SumNum[5] +'</td><td>'+ SumNum[6] +'</td></tr>'
					$('#tableChart_table').html('<table class="table table-bordered mt10"><td>控制</td><td>用地面积(hm2)</td><td>建筑面积(万m2)</td><td>居住户口(户)</td><td>停车位数(个)</td><td>容积率</td><td>建筑密度</td><td>绿地率</td></tr>'+addhtml+'</table>');
				}

				/*柱状图*/
	      	var myChart = echarts.init(document.getElementById('barGraph_table'));
	   		var option = {
            tooltip: {},
            legend: {
                data:['数据']
            },
            xAxis: {
                data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
            },
            yAxis: {},
            series: [{
                name: '数据',
                type: 'bar',
                data: [info.SHAPE_AREA,info.建筑面积,info.户数,info.停车位,info.容积率,info.建筑密度,info.绿地率]
            }]
        };
		 myChart.setOption(option);

		/*饼状图*/		 
			var myChart = echarts.init(document.getElementById('pieChart_table'));
				 option = {
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
		    },
		    series : [
		        {
		            name: '查询数据',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:[
		                {value:info.SHAPE_AREA, name:'用地面积(hm2)'},
		                {value:info.建筑面积, name:'建筑面积(万m2)'},
		                {value:info.户数, name:'居住户口(户)'},
		                {value:info.停车位, name:'停车位数(个)'},
		                {value:info.容积率, name:'容积率'},
		                {value:info.建筑密度, name:'建筑密度'},
		                {value:info.绿地率, name:'绿地率'}
		            ],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		};
	  myChart.setOption(option);
	            var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	            //先清空之前图层。
	            map.removeLayer(resultLayer_geometric);
	            resultLayer_geometric = new ol.layer.Vector({
	                source: vectorSource,
				});
				map.addLayer(resultLayer_geometric);
	        });
		});
	}
//多边形统计
	function _polygonalSelection(){
		//alert(1111);

		_clear();		
		var vector = new ol.layer.Vector({
			source: source
		});
		map.addLayer(vector);
		draw = new ol.interaction.Draw({
			source: source,
			type: 'Polygon',
			snapTolerance: 20
		});
		map.addInteraction(draw);
		draw.on('drawend',function(){
			var point = new ol.geom.Polygon(draw.a);
			var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
	            datasetNames: ["zonggui:ZG用地规划"],
	            geometry: point,
	            spatialQueryMode: "INTERSECT"
	        //    toIndex: 2000
	        });
	        new ol.supermap.FeatureService(urlData_2).getFeaturesByGeometry(geometryParam, function (serviceResult) {
				if(serviceResult.result.featureCount < 1)
					return;
				var allInfo = serviceResult.result.features.features;
				var info = serviceResult.result.features.features[0].properties; 				
				if(info != 'undefined'){
					$('#info-table').show();
					popup = new ol.Overlay({
						element: document.getElementById('info-table') 
					});
					map.addOverlay(popup);
					popup.setPosition([info.SMSDRIE,info.SMSDRIS]); 
					//处理结果-求和
					var addhtml="";
					var SumNum = new Array(0,0,0,0,0,0,0);
					for(var i=0; i<allInfo.length; i++){
						var thisInfo = allInfo[i].properties;
						if(thisInfo.SHAPE_AREA)
							SumNum[0] += parseFloat(thisInfo.SHAPE_AREA);
						if(thisInfo.建筑面积)
							SumNum[1] += parseFloat(thisInfo.建筑面积);
						if(thisInfo.户数)
							SumNum[2] += parseFloat(thisInfo.户数);
						if(thisInfo.停车位)
							SumNum[3] += parseFloat(thisInfo.停车位);
						if(thisInfo.容积率)
							SumNum[4] += parseFloat(thisInfo.容积率);
						if(thisInfo.建筑密度)
							SumNum[5] += parseFloat(thisInfo.建筑密度);
						if(thisInfo.绿地率)
							SumNum[6] += parseFloat(thisInfo.绿地率);

						addhtml += '<tr><td></td><td>' + getFloat2Num(parseFloat(thisInfo.SHAPE_AREA)) + '</td><td>' + getFloat2Num(parseFloat(thisInfo.建筑面积)) + '</td><td>' + thisInfo.户数 + '</td><td>' + thisInfo.停车位 + '</td><td>' + thisInfo.容积率 + '</td><td>' + thisInfo.建筑密度 + '</td><td>' + thisInfo.绿地率 + '</td></tr>';

					}
					//处理结果-求平均
					SumNum[4] = getFloat2Num( SumNum[4] / allInfo.length );
					SumNum[5] = getFloat2Num( SumNum[5] / allInfo.length );
					SumNum[6] = getFloat2Num( SumNum[6] / allInfo.length );

					addhtml += '<tr class="zongStr font-weight"><td>总计</td><td>'+ getFloat2Num(SumNum[0]) +'</td><td>'+ getFloat2Num(SumNum[1]) +'</td><td>'+ SumNum[2] +'</td><td>'+ SumNum[3] +'</td><td colspan="3"></td></tr>';
					addhtml += '<tr class="zongStr font-weight"><td>平均值</td><td colspan="4"></td><td>'+ SumNum[4] +'</td><td>'+ SumNum[5] +'</td><td>'+ SumNum[6] +'</td></tr>'
					$('#tableChart_table').html('<table class="table table-bordered mt10"><td>控制</td><td>用地面积(hm2)</td><td>建筑面积(万m2)</td><td>居住户口(户)</td><td>停车位数(个)</td><td>容积率</td><td>建筑密度</td><td>绿地率</td></tr>'+addhtml+'</table>');
				}
				/*柱状图*/
	      	var myChart = echarts.init(document.getElementById('barGraph_table'));
	   		var option = {
            tooltip: {},
            legend: {
                data:['数据']
            },
            xAxis: {
                data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
            },
            yAxis: {},
            series: [{
                name: '数据',
                type: 'bar',
                data: [info.SHAPE_AREA,info.建筑面积,info.户数,info.停车位,info.容积率,info.建筑密度,info.绿地率]
            }]
        };
		 myChart.setOption(option);

		/*饼状图*/		 
			var myChart = echarts.init(document.getElementById('pieChart_table'));
				 option = {
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        data: ["用地面积(hm2)","建筑面积(万m2)","居住户口(户)","停车位数(个)","容积率","建筑密度","绿地率"]
		    },
		    series : [
		        {
		            name: '查询数据',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:[
		                {value:info.SHAPE_AREA, name:'用地面积(hm2)'},
		                {value:info.建筑面积, name:'建筑面积(万m2)'},
		                {value:info.户数, name:'居住户口(户)'},
		                {value:info.停车位, name:'停车位数(个)'},
		                {value:info.容积率, name:'容积率'},
		                {value:info.建筑密度, name:'建筑密度'},
		                {value:info.绿地率, name:'绿地率'}
		            ],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		};
	  myChart.setOption(option);
	            var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	            //先清空之前图层。
	            map.removeLayer(resultLayer_gpolygonalSelection);
	            resultLayer_polygonalSelection = new ol.layer.Vector({
	                source: vectorSource,
				});
				map.addLayer(resultLayer_polygonalSelection);
	        });
		});
	}

//--------------------------------------------临时用-----------------------
//导出事件
var idTmr;
        function  getExplorer() {
            var explorer = window.navigator.userAgent ;
            //ie 
            if (explorer.indexOf("MSIE") >= 0) {
                return 'ie';
            }
            //firefox 
            else if (explorer.indexOf("Firefox") >= 0) {
                return 'Firefox';
            }
            //Chrome
            else if(explorer.indexOf("Chrome") >= 0){
                return 'Chrome';
            }
            //Opera
            else if(explorer.indexOf("Opera") >= 0){
                return 'Opera';
            }
            //Safari
            else if(explorer.indexOf("Safari") >= 0){
                return 'Safari';
            }
        }
       
        function _method1() {//整个表格拷贝到EXCEL中F
            if(getExplorer()=='ie')
            {
                var curTbl = document.getElementById('tTable');
                var oXL = new ActiveXObject("Excel.Application");

                //创建AX对象excel 
                var oWB = oXL.Workbooks.Add();
                //获取workbook对象 
                var xlsheet = oWB.Worksheets(1);
                //激活当前sheet 
                var sel = document.body.createTextRange();
                sel.moveToElementText(curTbl);
                //把表格中的内容移到TextRange中 
                sel.select;
                //全选TextRange中内容 
                sel.execCommand("Copy");
                //复制TextRange中内容  
                xlsheet.Paste();
                //粘贴到活动的EXCEL中       
                oXL.Visible = true;
                //设置excel可见属性

                try {
                    var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
                } catch (e) {
                    print("Nested catch caught " + e);
                } finally {
                    oWB.SaveAs(fname);

                    oWB.Close(savechanges = false);
                    //xls.visible = false;
                    oXL.Quit();
                    oXL = null;
                    //结束excel进程，退出完成
                    //window.setInterval("Cleanup();",1);
                    idTmr = window.setInterval("Cleanup();", 1);

                }

            }
            else
            {
                tableToExcel('tTable');
            }
        }
        function Cleanup() {
            window.clearInterval(idTmr);
            CollectGarbage();
        }
        var tableToExcel = (function() {
              var uri = 'data:application/vnd.ms-excel;base64,',
              template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
                base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
                format = function(s, c) {
                    return s.replace(/{(\w+)}/g,
                    function(m, p) { return c[p]; }) }
                return function(table, name) {
                if (!table.nodeType) table = document.getElementById(table)
                var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
                window.location.href = uri + base64(format(template, ctx))
              }
            })()


//--------------------------------------------------------------------------
/*-----------------------------tab控件-------------------------------------------------*/
$(function() {
        //$('#myTab a:first').tab('show'); //初始化显示哪个tab
        $('#myTab a').click(function(e) {
            e.preventDefault(); //阻止a链接的跳转行为
            $(this).tab('show'); //显示当前选中的链接及关联的content
        });
 

    });

//地图属性字段的导出
	function _educeInfo(){
		//修改方法
		dragBox_vectorInfo = new ol.interaction.DragBox({
	        condition: ol.events.condition.always
	    });
		map.addInteraction(dragBox_vectorInfo);
		
		dragBox_vectorInfo.on('boxend', function() {
			var extent = dragBox_vectorInfo.getGeometry();
			var polygon = extent;
			var geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
	            datasetNames: ["zonggui:ZG用地规划"],
	            geometry: polygon,
	            spatialQueryMode: "INTERSECT",
	            toIndex: 2000
	        });
	        new ol.supermap.FeatureService(urlData_2).getFeaturesByGeometry(geometryParam, function (serviceResult) {
				if(serviceResult.result.featureCount < 1)
					return;
	            var allInfo = serviceResult.result.features.features;
				var info = serviceResult.result.features.features[0].properties; 
				debugger
	             if(info != 'undefined'){
	            	$('#info-tab').show();
	           		popup = new ol.Overlay({
		         	   element: document.getElementById('info-tab')
		        	});
		        	map.addOverlay(popup);
            		popup.setPosition([info.SMSDRIE,info.SMSDRIS]);
            		//处理结果
            		var apphtml="";
         			var xh=0;
					for(var i=0; i<allInfo.length; i++){
						var thisInfo = allInfo[i].properties;
						xh++;
            		apphtml += '</td><td>'+xh+ '</td><td>' + thisInfo.SMID+ '</td><td>' + thisInfo.类型 + '</td><td>' + thisInfo.用地代 + '</td><td>' + thisInfo.SHAPE_AREA + '</td></tr>';
          			}
          			$('#tableChart').append('<table id="tTable" class="table table-bordered mt10"><td>序号</td><td>Smld</td><td>类型</td><td>用地代码</td><td>用地面积(hm2)</td></tr>'+apphtml+'</table>');               			
	      		  }

			/*柱状图*/
	      	var myChart = echarts.init(document.getElementById('barGraph'));
	   		var option = {
            tooltip: {},
            legend: {
                data:['数据']
            },
            xAxis: {
                data: ["xh","SMID","类型","用地代码","用地面积"]
            },
            yAxis: {},
            series: [{
                name: '数据',
                type: 'bar',
                data: [xh,thisInfo.SMID,thisInfo.类型,thisInfo.用地代,thisInfo.SHAPE_AREA]
            }]
        };
		 myChart.setOption(option);

		/*饼状图*/		 
			var myChart = echarts.init(document.getElementById('pieChart'));
				 option = {
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        data: ['xh','SMID','类型','用地代码','用地面积']
		    },
		    series : [
		        {
		            name: '查询数据',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:[
		                {value:xh, name:'xh'},
		                {value:thisInfo.SMID, name:'SMID'},
		                {value:thisInfo.类型, name:'类型'},
		                {value:thisInfo.用地代, name:'用地代码'},
		                {value:thisInfo.SHAPE_AREA, name:'用地面积'}
		            ],
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		};
	  myChart.setOption(option);
	           var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	           
	            //先清空之前图层。
	            map.removeLayer(resultLayer_vectorInfo);
	            resultLayer_vectorInfo = new ol.layer.Vector({
	                source: vectorSource,
				});
				map.addLayer(resultLayer_vectorInfo);
	        });
		});
	}

	 function _layerTree(){
	 	if($('#rightLayer').css('display')=='none'){
	 		$('#rightLayer').fadeIn(200);
	 	} else { 
	 		$('#rightLayer').fadeOut(200);
	 	}

	 	if($("#treeDemo").html() != '') return;
		layers = map.getLayers();
		tree = [];

		//obj传入类; typeOrNum传入first或num字符串; 
		var sub_layer = function(obj,typeOrNum){
			var info = {};
			if(typeOrNum=='first'){ 
				info.name = obj.name;
				info.id = obj.thisLayerId; //获取1级图层
				info.url = obj.thisPingYinUrl;
				//info.open=true;
			}else{
				info.name = obj.caption;
				info.id = typeOrNum;
			}
			//info.id = obj.ID;
			info.visible = obj.visible;
			if(typeof obj.subLayers.layers != 'undefined'){
 				var layer_count = obj.subLayers.layers.length;
				var nodes = [];
				for (var i=0; i < layer_count; i++) {
					if(typeOrNum=='first')
						var node = sub_layer(obj.subLayers.layers[i],i); //2级及以上图层
					else
						var node = sub_layer(obj.subLayers.layers[i],typeOrNum+'.'+i); //2级及以上图层
					nodes.push(node);
				}
				info.children = nodes;
			}/*else{
				info.lists = false;
			}*/
			return info;
		}

		//获取数据集中数据.
		var LayerAutoNum = 0;
		var SuperMapAutoSendToTree = function(){
			if(LayerAutoNum<layers.getLength()){
				var url = layers.item(LayerAutoNum).get('source')._url;
				var supermapLayerInfoService = new ol.supermap.LayerInfoService(url);
				supermapLayerInfoService.getLayersInfo(function (serviceResult) {
					var layer_l1 = serviceResult.result;
					layer_l1.thisLayerId = LayerAutoNum; //1级图层
					layer_l1.thisPingYinUrl = url; //1级图层
					tree.push(sub_layer(layer_l1,'first'));
					LayerAutoNum++;
					SuperMapAutoSendToTree();
				});
			}
		}
		SuperMapAutoSendToTree();
		setTimeout(function (){
			showLayerTree(tree);
	 },1000);
  }
    
    showLayerTree = function(data){
    	var zNodes =data;
    	var setting = {
    		check: {
    			enable: true,
    			chkStyle: "checkbox"
    		}
    	};
		$.fn.zTree.init($('#treeDemo'), setting, zNodes);
	}
	
	/******************** 二维图层显隐开始 ********************/
	//图层开关
	var markId;
	var layers = {};
	function  _getLayer(markId1){
		markId=markId1;
		if (markId=='#rightLayer #getLayerTree') {
			if($('#rightLayer').css('display')=='none'){
				$('#rightLayer').fadeIn(200);
			} else { 
				$('#rightLayer').fadeOut(200);
			}
		}

		if($(markId).html() != '') return;
		layers = map.getLayers();
		tree = [];
		//obj传入类; typeOrNum传入first或num字符串; 
		var sub_layer = function(obj,typeOrNum){
			var info = {};
			if(typeOrNum=='first'){ 
				info.name = obj.name;
				info.layerID = obj.thisLayerId; //获取1级图层
				info.thisPingYinUrl = obj.thisPingYinUrl;
			}else{
				info.name = obj.caption;
				info.layerID = typeOrNum;
			}
			info.id = obj.ID;
			info.visible = obj.visible;
			if(typeof obj.subLayers.layers != 'undefined'){
				var layer_count = obj.subLayers.layers.length;
				var nodes = [];
				for (var i=0; i < layer_count; i++) {
					if(typeOrNum=='first')
						var node = sub_layer(obj.subLayers.layers[i],i); //2级及以上图层
					else
						var node = sub_layer(obj.subLayers.layers[i],typeOrNum+'.'+i); //2级及以上图层
					nodes.push(node);
				}
				info.lists = nodes;
			}else{
				info.lists = false;
			}
			return info;
		}

		//获取数据集中数据.
		var LayerAutoNum = 0;
		var SuperMapAutoSendToTree = function(){
			if(LayerAutoNum<layers.getLength()){
				var url = layers.item(LayerAutoNum).get('source')._url;
				var supermapLayerInfoService = new ol.supermap.LayerInfoService(url);
				supermapLayerInfoService.getLayersInfo(function (serviceResult) {
					var layer_l1 = serviceResult.result;
					
					layer_l1.thisLayerId = LayerAutoNum; //1级图层
					layer_l1.thisPingYinUrl = url; //1级图层
					tree.push(sub_layer(layer_l1,'first'));
					LayerAutoNum++;
					SuperMapAutoSendToTree();
				});
			}
		}
		SuperMapAutoSendToTree();

		//load
		$(markId).html("<span>loading...</span>");
		//$('#getLayerTree').html("<span>loading...</span>");
		//加载
		setTimeout(function(){
			/*递归实现获取无级树数据并生成DOM结构*/
			var str = "";
			/*添加无级树*/
			$(markId).html(forTree(tree));
			//$('#getLayerTree').html(forTree(tree));
			//给有子对象的元素加[+-]
			$(markId+" ul").each(function(index, element) {
			//$("#getLayerTree ul").each(function(index, element) {
				var ulContent = $(element).html();
				var spanContent = $(element).siblings("span").html();
				if (ulContent) {
					$(element).siblings("span").html("<i class='ace-icon fa fa-plus'></i> " + spanContent)
				} else {
					$(element).siblings("span").html("<i class='ace-icon fa fa-minus'></i> " + spanContent);
				}
			});
			//循环遍历数组id
			for (var i = 0; i < defaultShowArray.length; i++) {
				// 设置显示图层的选中状态
				$(".a" + defaultShowArray[i]).attr("checked", "checked");
			}


			//设置默认显示
			var foreachTree = $(markId+'> .TreeAutoCreate');
			//var foreachTree = $('#getLayerTree > .TreeAutoCreate');
			for(var i=0; i<foreachTree.length; i++){
				//全部隐藏
				foreachTree.eq(i).find('input:first').click();
			}
			//仅显示[用地规划][底图]
			$(markId+'> .TreeAutoCreate').eq(5).find('input:first').click();
			$(markId+'> .TreeAutoCreate').eq(7).find('input:first').click();
			//$('#getLayerTree > .TreeAutoCreate').eq(5).find('input:first').click();
			//$('#getLayerTree > .TreeAutoCreate').eq(7).find('input:first').click();

		},1000);

	}

    // 创建无级树
	forTree = function(data) {
		for(var i = data.length-1; i >=0; i--) {
			var urlstr = "";
			try { 
				if (data[i]["lists"] == false) {
					urlstr = "<div class='TreeAutoCreate' thisid='" + data[i]["layerID"] + "' ><span><input type='checkbox' checked='checked'> <a href='#'>" + data[i]["name"] + "</a></span><ul style='display:block;'>";
				} else {
					urlstr = "<div class='TreeAutoCreate' thisid='" + data[i]["layerID"] + "' thisurl='" + data[i]["thisPingYinUrl"] + "'><span><input type='checkbox' checked='checked'> <a href='#'>" + data[i]["name"] + "</a></span><ul style='display:none;'>";
				}
				str += urlstr;
				if (data[i]["lists"] != false) {
					forTree(data[i]["lists"]);
				}
				str += "</ul></div>";
				if (data[i]["defaultshow"] == 1) {
					defaultShowArray.push(data[i]["id"]);
				}
			} catch(e) {}
		}
		return str;
	}
	
	//图层的展开关闭
	var str = "";
	var defaultShowArray = new Array();
	var menuTree = function() {	
		$('#getLayerTree').on("click","span a",function() {
			var ul = $(this).parent().siblings("ul");
			$(this).parent().find("i").remove();
			var spanStr = $(this).parent().html();
			var spanContent = spanStr;
			var addStr = "";
			var that = $(this).parent();
			//program
			if (ul.css("display") == "none") {
				ul.show(300);
				that.html("");
				addStr = "<i class='ace-icon fa fa-minus'></i> " + spanContent;
				that.html(addStr);
			} else {
				ul.hide(300);
				that.html("");
				addStr = "<i class='ace-icon fa fa-plus'></i> " + spanContent;
				that.html(addStr);
			}
		})
	}();

	//右边工具栏图层的展开关闭
	var str = "";
	var defaultShowArray = new Array();
	var menuTree = function() {	
		$('#rightLayer #getLayerTree').on("click","span a",function() {
			var ul = $(this).parent().siblings("ul");
			$(this).parent().find("i").remove();
			var spanStr = $(this).parent().html();
			var spanContent = spanStr;
			var addStr = "";
			var that = $(this).parent();
			//program
			if (ul.css("display") == "none") {
				ul.show(300);
				that.html("");
				addStr = "<i class='ace-icon fa fa-minus'></i> " + spanContent;
				that.html(addStr);
			} else {
				ul.hide(300);
				that.html("");
				addStr = "<i class='ace-icon fa fa-plus'></i> " + spanContent;
				that.html(addStr);
			}
		})
	}();

	//设置子图层的开关
	var isHideLayer = function(othis) {
		var Result = getPingYinUrl(othis);
		var funNewSource = new ol.source.TileSuperMapRest({
				url: Result.url,
				layersID: Result.str
			});
    	pingyinLayer[Result.mapnameID].setSource(funNewSource);
	}

	/*
	 * 查找当前图层下全部图层的拼接
	 * 文献：http://support.supermap.com.cn:8090/iserver/help/html/zh/mergedProjects/SuperMapiServerRESTAPI/root/maps/map/tileImage.htm#GET%E8%AF%B7%E6%B1%82
	 */
	var getPingYinUrl = function(othis){
		//获取最上层
		var parentTreeAutoCreate = $(othis).parents('.TreeAutoCreate:last');
		var AllTreeAutoCreate = parentTreeAutoCreate.find('.TreeAutoCreate');
		var result = []; 
		//获取当前操作url
		result.url = parentTreeAutoCreate.attr('thisurl');
		//获取当前操作的地图字符串
		result.mapnameID = parentTreeAutoCreate.attr('thisid');
		//获取拼接后的字符串
		var AlllayerString = "[0:"; 
		var pre = ""; 
		var truefalse = false; 
		for(var i=AllTreeAutoCreate.length; i>=0; i--){ 
			var thisTreeEqVal = AllTreeAutoCreate.eq(i); 
			if(thisTreeEqVal.find('.TreeAutoCreate').length<1){  //只获取最底层图层
				if(thisTreeEqVal.find('input:first').is(':checked')){  //被选定状态进行操作
					var thisid = thisTreeEqVal.attr('thisid'); 
					AlllayerString += pre + thisid; 
					pre = ","; 
					truefalse = true;
				} 	
			}
		} 
		AlllayerString += "]";
		result.str = AlllayerString;

		//判断truefalse为真则显示，否则隐藏。
		if(truefalse)
			layers.item(result.mapnameID).setVisible(true);
		else
			layers.item(result.mapnameID).setVisible(false);
		//返回结果集		
		return result;
	}
	
	//控制图层的显示隐藏
	$("#getLayerTree").on("click", "input",function() {
		// 获取点击的的图层的input的class名称
		var classname = $(this).attr('class');
		// 获取点击的图层的input的图层名称
		var thisname = $(this).next().html();
		// 获取当前图层包含的所有子节点
		var childArry = $(this).parent().next().find("input[type='checkbox']");
		// 判断是否选中状态
		var selected = $(this).is(':checked');
		//获取当前ID
		var thisid = $(this).parents('div').attr('thisid');
		//判断当前上面有几层
		var thislayerNum = $(this).parents('.TreeAutoCreate');
		/**
		 * 1 先判断是 图层开关 还是 子图层开关.
		 * --如果是图层开关直接找到对应ID layers.item(thisid).setVisible(true);
		 * --如果是子图层先判断是哪个大图层下的小图层
		 */
		if (selected == true) {
			//当前节点
			$(this).prop("checked", true);
			$(this).attr("checked", "checked");
			//所有子节点
			childArry.attr('checked','checked');
			childArry.prop("checked", true);
			//操作hide/show
			if(thislayerNum.length>1){
				isHideLayer(this); //控制子图层的hide/show
			} else {
				isHideLayer(this)
				layers.item(thisid).setVisible(true); //控制地图的hide/show
				FlyLayerOpen[thisid] = true;
			}
		} else {
			//当前节点
			$(this).prop("checked", false);
			$(this).removeAttr("checked");
			//所有子节点
			childArry.removeAttr('checked');
			//操作hide/show
			if(thislayerNum.length>1){
				isHideLayer(this); //控制子图层的hide/show
			} else {
				isHideLayer(this)
				layers.item(thisid).setVisible(false); //控制地图的hide/show
				FlyLayerOpen[thisid] = false;
			}
		}
		//执行回路函数调用.
		eval(returnFunction);
	});

	//右边工具栏控制图层的显示隐藏
	$("#rightLayer #getLayerTree").on("click", "input",function() {
		// 获取点击的的图层的input的class名称
		var classname = $(this).attr('class');
		// 获取点击的图层的input的图层名称
		var thisname = $(this).next().html();
		// 获取当前图层包含的所有子节点
		var childArry = $(this).parent().next().find("input[type='checkbox']");
		// 判断是否选中状态
		var selected = $(this).is(':checked');
		//获取当前ID
		var thisid = $(this).parents('div').attr('thisid');
		//判断当前上面有几层
		var thislayerNum = $(this).parents('.TreeAutoCreate');
		/**
		 * 1 先判断是 图层开关 还是 子图层开关.
		 * --如果是图层开关直接找到对应ID layers.item(thisid).setVisible(true);
		 * --如果是子图层先判断是哪个大图层下的小图层
		 */
		if (selected == true) {
			//当前节点
			$(this).prop("checked", true);
			$(this).attr("checked", "checked");
			//所有子节点
			childArry.attr('checked','checked');
			childArry.prop("checked", true);
			//操作hide/show
			if(thislayerNum.length>1){
				isHideLayer(this); //控制子图层的hide/show
			} else {
				isHideLayer(this)
				layers.item(thisid).setVisible(true); //控制地图的hide/show
				FlyLayerOpen[thisid] = true;
			}
		} else {
			//当前节点
			$(this).prop("checked", false);
			$(this).removeAttr("checked");
			//所有子节点
			childArry.removeAttr('checked');
			//操作hide/show
			if(thislayerNum.length>1){
				isHideLayer(this); //控制子图层的hide/show
			} else {
				isHideLayer(this)
				layers.item(thisid).setVisible(false); //控制地图的hide/show
				FlyLayerOpen[thisid] = false;
			}
		}
		//执行回路函数调用.
		eval(returnFunction);
	});
	/******************** 二维图层显隐结束 ********************/




	//卷帘功能实现
	function _WindowCurtains(){
	    //清除
		_clear();
		//
		returnFunction = "_WindowCurtains()";
	    var swipe = document.getElementById('swipInput');
	    swipe.style.display = "block";
	    //取消其他图层的绑定;
	    //不需要则开始执行以下代码
	    var lastNum = -1;
	    for(var i=FlyLayerOpen.length-1; i>=0; i--){
	    	if(FlyLayerOpen[i]==true && i>lastNum)
	    		lastNum = i;
	    }
	    if(lastNum>1){
	    	//清除当前监听绑定
	    	//pingyinLayer[lastNum].un('precompose');
	    	//pingyinLayer[lastNum].un('postcompose');

			//多重加载  【多个图层进行了绑定，未能清除图层监听事件】
	    	pingyinLayer[lastNum].on('precompose', function (event) {
		        var ctx = event.context;
				var width = ctx.canvas.width * (swipe.value / 100);
		        ctx.save();
		        ctx.beginPath();
		        ctx.rect(width, 0, ctx.canvas.width - width, ctx.canvas.height);
		        ctx.clip();
		    });
		    pingyinLayer[lastNum].on('postcompose', function (event) {
		        var ctx = event.context;
		        ctx.restore();
		    });
	    }
	    swipe.addEventListener('input', function () {
	        map.render();
	    }, false);

	    //函数监听池中swipe设为true
	    FunctionAddEvent.swipe = true;
	}


	//条件查询
	function _sqlselect(){	
		//init
		var htmlValue = new Array(
			$('#sqlselectText1').val(),
			$('.layui-select-title input').eq(1).val(),
			$('#sqlselectText2').val()
		);	
		//select选择对应操作的图层 
		var thisLayerInfo = getSelectLayer( $('.layui-select-title input').eq(0).val() ); 
		thisLayerInfo.queryParams = thisLayerInfo.parameter + htmlValue[1] + htmlValue[2];
		//开始.
		var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
            queryParameter: {
                name: thisLayerInfo.name,
                attributeFilter: thisLayerInfo.queryParams
            },
            datasetNames: thisLayerInfo.datasetNames,
            toIndex: 2000
        }); 
        new ol.supermap.FeatureService(thisLayerInfo.url).getFeaturesBySQL(sqlParam, function (serviceResult) {
			if(serviceResult.result){
				var vectorSource = new ol.source.Vector({
	                features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.features),
	                wrapX: false
	            });
	            //删除之前添加的图层，避免重复
	            if(resultLayer_sqlselect)
	                map.removeLayer(resultLayer_sqlselect);
	            resultLayer_sqlselect = new ol.layer.Vector({
	                source: vectorSource
	            });
	            map.addLayer(resultLayer_sqlselect);
			}
        });
	}
	//获取条件查询-所操作的图层ID  [辅助上面查询]
	function getSelectLayer(str){
		var thisLayerInfo = [];
		var thisLayerNum = SqlSelectJson;
		for(var i=0; i<thisLayerNum.length; i++){
			var thisinfo = thisLayerNum[i];
			if(str == thisinfo.showName){
				thisLayerInfo = thisinfo; //图层名称
			}
		}
		return thisLayerInfo;
	}

	//表面分析
	function _surfaceAnalysis() {
		function addInteraction() {
			var value = "Box";
			if (value !== 'None') {
				var geometryFunction;
				if (value === 'Box') {
					value = 'Circle';
					geometryFunction = ol.interaction.Draw.createBox();
				}
				draw = new ol.interaction.Draw({
					source: source,
					type: value,
					geometryFunction: geometryFunction
				});

				map.addInteraction(draw);
			}
		}

		map.removeInteraction(draw);
		addInteraction();

		draw.on('drawend', function (e) {
			var options, surfaceAnalystService, surfaceAnalystParameters;
			var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[1]);

			var mapService = new ol.supermap.MapService(urlPingyinToUrl);
			var extent = e.feature.N.geometry.s;
			mapService.getMapInfo(function (serviceResult) {
				var mapJSONObj = serviceResult.result;
				options = ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj);
				var layer = new ol.layer.Tile({
					source: new ol.source.TileSuperMapRest(options)
				});
				surfaceAnalystProcess();
			});
			function surfaceAnalystProcess() {
				//创建表面分析服务参数
				var region = new ol.geom.Polygon([[
					[extent[0], extent[1]],
					[extent[2], extent[1]],
					[extent[2], extent[3]],
					[extent[0], extent[3]]
				]]);
				surfaceAnalystParameters = new SuperMap.DatasetSurfaceAnalystParameters({
					extractParameter: new SuperMap.SurfaceAnalystParametersSetting({
						datumValue: 0,
						interval: 2,
						resampleTolerance: 0,
						smoothMethod: SuperMap.SmoothMethod.BSPLINE,
						smoothness: 3,
						clipRegion: region
					}),
					dataset: "DEM@Raster", //"ZG电力站点@zonggui",
					resolution: 15, //1000,
					zValueFieldName: "负荷"
				});
				//创建表面分析服务实例
				surfaceAnalystService = new ol.supermap.SpatialAnalystService(spaceData);
				surfaceAnalystService.surfaceAnalysis(surfaceAnalystParameters, function (surfaceAnalystServiceResult) {
					var result = surfaceAnalystServiceResult.result;
					if (result && result.recordset && result.recordset.features) {
						resultLayer_surfaceAnalysis = new ol.layer.Vector({
							source: new ol.source.Vector({
								features: (new ol.format.GeoJSON()).readFeatures(result.recordset.features)
							}),
							style: new ol.style.Style({
								stroke: new ol.style.Stroke({
									color: 'rgba(100, 100, 225, 10)',
									width: 1.5
								}),
								fill: new ol.style.Fill({
									color: 'rgba(0, 0, 255, 0.1)'
								})
							})
						});
						map.addLayer(resultLayer_surfaceAnalysis);
					}
				});
			}
		});
	}



	/*
	 * 缓冲区分析  [仅操作用地规划]
	 * 
	 * 1 通过监听获取到点坐标
	 * 2 查询到线坐标，案例：http://iclient.supermapol.com/examples/openlayers/editor.html#02_getFeatureByGeometry
	 * 3 获取到线坐标后进行缓冲区分析.
	 */
	var getThisLayerInfo;
	function _bufferAnalyse() {
		getThisLayerInfo = function(serviceInfo){
			var FlyPoint = new ol.geom.Point([serviceInfo.coordinate[0], serviceInfo.coordinate[1]]);		
			// 通过距离查询的方式获取数据
			var bufferParam = new SuperMap.GetFeaturesByBufferParameters({
	            datasetNames: ["zonggui:ZG道路交通"],
	            bufferDistance: 30,
	            geometry: FlyPoint
	        });
	        new ol.supermap.FeatureService(urlData_1).getFeaturesByBuffer(bufferParam, function (serviceResult) {
	        	var NewCoordinates = serviceResult.result.features.features;
	        	//for(var i=0; i<NewCoordinates.length; i++){
					var ThisInfo = NewCoordinates[0].geometry.coordinates;
					var loadSMID = serviceResult.result.features.features[0].properties["SMID"];
					// loadSMID = parseInt(loadSMID);
					
					//此处开始写相应代码 【注意:代码处于循环中.】
					// console.log(serviceResult.result);
					// console.log(ThisInfo);
					// console.log(loadSMID);
					// console.log(typeof(loadSMID));
										
					var extent = [445578.46, 4011180.32, 455644.02, 4020147.37];
					var projection = new ol.proj.Projection({
						extent: extent,
						units: 'm'
					});

					var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[2]);
					new ol.supermap.MapService(urlPingyinToUrl).getMapInfo(function (serviceResult) {
						var mapJSONObj = serviceResult.result;						
						var layer = new ol.layer.Tile({
							source: new ol.source.TileSuperMapRest(ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj))
						});						

						roadLine = new ol.geom.LineString(ThisInfo);
						
						var vectorSource = new ol.source.Vector({
							features: [new ol.Feature(roadLine)]
						});
						var vectorLayer = new ol.layer.Vector({
							source: vectorSource,
							style: new ol.style.Style({
								stroke: new ol.style.Stroke({
									color: 'blue',
									width: 3
								}),
								fill: new ol.style.Fill({
									color: 'rgba(0, 0, 255, 0.1)'
								})
							})
						});
						map.addLayer(vectorLayer);
						bufferAnalystProcess();
					});

					function bufferAnalystProcess() {
						var dsBufferAnalystParameters = new SuperMap.DatasetBufferAnalystParameters({
							dataset: "ZG道路交通@zonggui",
							filterQueryParameter: new SuperMap.FilterParameter({
								attributeFilter: "SMID="+loadSMID
								//  attributeFilter:"道路名='翠屏街'"
							}),
							bufferSetting: new SuperMap.BufferSetting({
								endType: SuperMap.BufferEndType.ROUND,
								leftDistance: {value: 300},
								rightDistance: {value: 300},
								semicircleLineSegment: 4
							})
						});
						//console.log(dsBufferAnalystParameters);
						new ol.supermap.SpatialAnalystService(spaceData).bufferAnalysis(dsBufferAnalystParameters, function (serviceResult) {
							if(serviceResult.result.recordset){
								var vectorSource = new ol.source.Vector({
									features: (new ol.format.GeoJSON()).readFeatures(serviceResult.result.recordset.features)
								});
								resultLayer_bufferAnalyse = new ol.layer.Vector({
									source: vectorSource,
									style: new ol.style.Style({
										stroke: new ol.style.Stroke({
											color: 'red',
											width: 1
										}),
										fill: new ol.style.Fill({
											color: 'rgba(255, 0, 0, 0.1)'
										})
									})
								});							
								map.addLayer(resultLayer_bufferAnalyse);
							}
						});
					}
	        	//}
	        });
		}
		FunctionAddEvent.bufferAnalyse = true;
		var UserEventClick = map.on('click',getThisLayerInfo);
	}


	//点密度
	function _dotDensity() {
		var options, interpolationAnalystResult;
		var extent = [440006.88, 4008876.63, 460594.99, 4023235.27];
		var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[3]);
		new ol.supermap.MapService(urlPingyinToUrl).getMapInfo(function (serviceResult) {
			;
			var mapJSONObj = serviceResult.result;
			options = ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj);
			var layer = new ol.layer.Tile({
				source: new ol.source.TileSuperMapRest(options)
			});
			interpolationAnalystProcess();
		});
		function interpolationAnalystProcess() {
			//创建点密度插值分析参数实例
			var interpolationAnalystParameters = new SuperMap.InterpolationDensityAnalystParameters({
				//用于做插值分析的数据源中数据集的名称
				dataset: "ZG电力站点@zonggui",
				// dataset:["zonggui:ZG电力站点"],
				//插值分析结果数据集的名称
				outputDatasetName: "Interpolation_Result",
				//插值分析结果数据源的名称
				outputDatasourceName: "zonggui",
				//结果栅格数据集存储的像素格式
				pixelFormat: SuperMap.PixelFormat.DOUBLE,
				//插值结果栅格数据集的分辨率
				resolution: 30,
				// 存储用于进行插值分析的字段名称
				zValueFieldName: "负荷",
				//结果栅格数据集的范围（生效）
				bounds: [440006.88, 4008876.63, 460594.99, 4023235.27]
			});

			new ol.supermap.SpatialAnalystService(spaceData).interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {

				interpolationAnalystResult = serviceResult.result;
				//用栅格专题图展示分析结果
				showAnalysisResult_ThemeGridRange();
			});

			//构造栅格专题图
			function showAnalysisResult_ThemeGridRange() {
				var color1 = new SuperMap.ServerColor(170, 240, 233),
					color2 = new SuperMap.ServerColor(176, 244, 188),
					color3 = new SuperMap.ServerColor(218, 251, 178),
					color4 = new SuperMap.ServerColor(220, 236, 145),
					color5 = new SuperMap.ServerColor(96, 198, 66),
					color6 = new SuperMap.ServerColor(20, 142, 53),
					color7 = new SuperMap.ServerColor(85, 144, 55),
					color8 = new SuperMap.ServerColor(171, 168, 38),
					color9 = new SuperMap.ServerColor(235, 165, 9),
					color10 = new SuperMap.ServerColor(203, 89, 2),
					color11 = new SuperMap.ServerColor(157, 25, 1),
					color12 = new SuperMap.ServerColor(118, 15, 3),
					color13 = new SuperMap.ServerColor(112, 32, 7),
					color14 = new SuperMap.ServerColor(106, 45, 12),
					color15 = new SuperMap.ServerColor(129, 80, 50),
					color16 = new SuperMap.ServerColor(160, 154, 146),
					color17 = new SuperMap.ServerColor(107, 47, 14),
					color18 = new SuperMap.ServerColor(125, 75, 44),
					color19 = new SuperMap.ServerColor(146, 110, 88),
					color20 = new SuperMap.ServerColor(166, 153, 146);

				var themeGridRangeItem1 = new SuperMap.ThemeGridRangeItem({
						start: 0,
						end: 10,
						color: color1
					}),
					themeGridRangeItem2 = new SuperMap.ThemeGridRangeItem({
						start: 10,
						end: 20,
						color: color2
					}),
					themeGridRangeItem3 = new SuperMap.ThemeGridRangeItem({
						start: 20,
						end: 30,
						color: color3
					}),
					themeGridRangeItem4 = new SuperMap.ThemeGridRangeItem({
						start: 30,
						end: 40,
						color: color4
					}),
					themeGridRangeItem5 = new SuperMap.ThemeGridRangeItem({
						start: 40,
						end: 50,
						color: color5
					}),
					themeGridRangeItem6 = new SuperMap.ThemeGridRangeItem({
						start: 50,
						end: 60,
						color: color6
					}),
					themeGridRangeItem7 = new SuperMap.ThemeGridRangeItem({
						start: 60,
						end: 70,
						color: color7
					}),
					themeGridRangeItem8 = new SuperMap.ThemeGridRangeItem({
						start: 70,
						end: 80,
						color: color8
					}),
					themeGridRangeItem9 = new SuperMap.ThemeGridRangeItem({
						start: 80,
						end: 90,
						color: color9
					}),
					themeGridRangeItem10 = new SuperMap.ThemeGridRangeItem({
						start: 90,
						end: 100,
						color: color10
					}),
					themeGridRangeItem11 = new SuperMap.ThemeGridRangeItem({
						start: 100,
						end: 110,
						color: color11
					}),
					themeGridRangeItem12 = new SuperMap.ThemeGridRangeItem({
						start: 110,
						end: 120,
						color: color12
					}),
					themeGridRangeItem13 = new SuperMap.ThemeGridRangeItem({
						start: 120,
						end: 130,
						color: color13
					}),
					themeGridRangeItem14 = new SuperMap.ThemeGridRangeItem({
						start: 130,
						end: 140,
						color: color14
					}),
					themeGridRangeItem15 = new SuperMap.ThemeGridRangeItem({
						start: 140,
						end: 150,
						color: color15
					}),
					themeGridRangeItem16 = new SuperMap.ThemeGridRangeItem({
						start: 150,
						end: 160,
						color: color16
					}),
					themeGridRangeItem17 = new SuperMap.ThemeGridRangeItem({
						start: 160,
						end: 170,
						color: color17
					}),
					themeGridRangeItem18 = new SuperMap.ThemeGridRangeItem({
						start: 170,
						end: 180,
						color: color18
					}),
					themeGridRangeItem19 = new SuperMap.ThemeGridRangeItem({
						start: 180,
						end: 190,
						color: color19
					}),
					themeGridRangeItem20 = new SuperMap.ThemeGridRangeItem({
						start: 190,
						end: 220,
						color: color20
					});

				var themeGridRange = new SuperMap.ThemeGridRange({
					reverseColor: false,
					rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
					//栅格分段专题图子项数组
					items: [themeGridRangeItem1, themeGridRangeItem2,
						themeGridRangeItem3, themeGridRangeItem4,
						themeGridRangeItem5, themeGridRangeItem6,
						themeGridRangeItem7, themeGridRangeItem8,
						themeGridRangeItem9, themeGridRangeItem10,
						themeGridRangeItem11, themeGridRangeItem12,
						themeGridRangeItem13, themeGridRangeItem14,
						themeGridRangeItem15, themeGridRangeItem16,
						themeGridRangeItem17, themeGridRangeItem18,
						themeGridRangeItem19, themeGridRangeItem20
					]
				});

				var themeParameters = new SuperMap.ThemeParameters({
					//制作专题图的数据集
					datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
					dataSourceNames: ["zonggui"],
					joinItems: null,
					themes: [themeGridRange]
				});

				new ol.supermap.ThemeService(urlPingyinToUrl).getThemeInfo(themeParameters, function (serviceResult) {
					var result = serviceResult.result;
					if (result && result.newResourceID) {
						themeLayer_dotDensity = new ol.layer.Tile({
							source: new ol.source.TileSuperMapRest({
								url: urlPingyinToUrl,
								noWrap: true,
								cacheEnabled: false,
								transparent: true,
								layersID: result.newResourceID,
								tileGrid: new ol.tilegrid.TileGrid({
									extent: extent,
									resolutions: options.tileGrid.getResolutions()
								}),
								transparent: true,
								opacity: 0.1
							})
						});
						map.addLayer(themeLayer_dotDensity);
						//添加外围范围显示
						flyRangeLayer();
					}
				});
			}
		}
	}

	//反距离
	function _reverseDistance() {
		var options, interpolationAnalystResult;
		var extent = [440006.88, 4008876.63, 460594.99, 4023235.27];
		var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[3]);
		new ol.supermap.MapService(urlPingyinToUrl).getMapInfo(function (serviceResult) {
			;
			var mapJSONObj = serviceResult.result;
			options = ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj);
			var layer = new ol.layer.Tile({
				source: new ol.source.TileSuperMapRest(options)
			});
			interpolationAnalystProcess();
		});

		function interpolationAnalystProcess() {
			//创建反距离加权插值分析参数实例
			var interpolationAnalystParameters = new SuperMap.InterpolationIDWAnalystParameters({
				//用于做插值分析的数据源中数据集的名称
				dataset: "ZG电力站点@zonggui",
				//插值分析结果数据集的名称
				outputDatasetName: "IDW_Result",
				//插值分析结果数据源的名称
				outputDatasourceName: "zonggui",
				//结果栅格数据集存储的像素格式
				pixelFormat: SuperMap.PixelFormat.DOUBLE,
				// 属性过滤条件
				// filterQueryParameter: {
				// attributeFilter: ""
				// },
				//存储用于进行插值分析的字段名称
				zValueFieldName: "负荷",
				//插值结果栅格数据集的分辨率
				resolution: 30,
				//采取固定点数查找参与运算点的方式
				searchMode: "KDTREE_FIXED_COUNT",
				//固定点数查找方式下,参与差值运算的点数默认为12。
				expectedCount: 12,
				bounds: [440006.88, 4008876.63, 460594.99, 4023235.27]
			});
			new ol.supermap.SpatialAnalystService(spaceData).interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {
				interpolationAnalystResult = serviceResult.result;
				//用栅格专题图展示分析结果
				showAnalysisResult_ThemeGridRange();
			});

			//构造栅格专题图
			function showAnalysisResult_ThemeGridRange() {
				var color1 = new SuperMap.ServerColor(170, 240, 233),
					color2 = new SuperMap.ServerColor(176, 244, 188),
					color3 = new SuperMap.ServerColor(218, 251, 178),
					color4 = new SuperMap.ServerColor(220, 236, 145),
					color5 = new SuperMap.ServerColor(96, 198, 66),
					color6 = new SuperMap.ServerColor(20, 142, 53),
					color7 = new SuperMap.ServerColor(85, 144, 55),
					color8 = new SuperMap.ServerColor(171, 168, 38),
					color9 = new SuperMap.ServerColor(235, 165, 9),
					color10 = new SuperMap.ServerColor(203, 89, 2),
					color11 = new SuperMap.ServerColor(157, 25, 1),
					color12 = new SuperMap.ServerColor(118, 15, 3),
					color13 = new SuperMap.ServerColor(112, 32, 7),
					color14 = new SuperMap.ServerColor(106, 45, 12),
					color15 = new SuperMap.ServerColor(129, 80, 50),
					color16 = new SuperMap.ServerColor(160, 154, 146),
					color17 = new SuperMap.ServerColor(107, 47, 14),
					color18 = new SuperMap.ServerColor(125, 75, 44),
					color19 = new SuperMap.ServerColor(146, 110, 88),
					color20 = new SuperMap.ServerColor(166, 153, 146);

				var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
					start: 0,
					end: 10,
					color: color1
				}),
					themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
						start: 10,
						end: 20,
						color: color2
					}),
					themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
						start: 20,
						end: 30,
						color: color3
					}),
					themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
						start: 30,
						end: 40,
						color: color4
					}),
					themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
						start: 40,
						end: 50,
						color: color5
					}),
					themeGridRangeIteme6 = new SuperMap.ThemeGridRangeItem({
						start: 50,
						end: 60,
						color: color6
					}),
					themeGridRangeIteme7 = new SuperMap.ThemeGridRangeItem({
						start: 60,
						end: 70,
						color: color7
					}),
					themeGridRangeIteme8 = new SuperMap.ThemeGridRangeItem({
						start: 70,
						end: 80,
						color: color8
					}),
					themeGridRangeIteme9 = new SuperMap.ThemeGridRangeItem({
						start: 80,
						end: 90,
						color: color9
					}),
					themeGridRangeIteme10 = new SuperMap.ThemeGridRangeItem({
						start: 90,
						end: 100,
						color: color10
					}),
					themeGridRangeIteme11 = new SuperMap.ThemeGridRangeItem({
						start: 100,
						end: 110,
						color: color11
					}),
					themeGridRangeIteme12 = new SuperMap.ThemeGridRangeItem({
						start: 110,
						end: 120,
						color: color12
					}),
					themeGridRangeIteme13 = new SuperMap.ThemeGridRangeItem({
						start: 120,
						end: 130,
						color: color13
					}),
					themeGridRangeIteme14 = new SuperMap.ThemeGridRangeItem({
						start: 130,
						end: 140,
						color: color14
					}),
					themeGridRangeIteme15 = new SuperMap.ThemeGridRangeItem({
						start: 140,
						end: 150,
						color: color15
					}),
					themeGridRangeIteme16 = new SuperMap.ThemeGridRangeItem({
						start: 150,
						end: 160,
						color: color16
					}),
					themeGridRangeIteme17 = new SuperMap.ThemeGridRangeItem({
						start: 160,
						end: 170,
						color: color17
					}),
					themeGridRangeIteme18 = new SuperMap.ThemeGridRangeItem({
						start: 170,
						end: 180,
						color: color18
					}),
					themeGridRangeIteme19 = new SuperMap.ThemeGridRangeItem({
						start: 180,
						end: 200,
						color: color19
					}),
					themeGridRangeIteme20 = new SuperMap.ThemeGridRangeItem({
						start: 200,
						end: 220,
						color: color20
					});

				var themeGridRange = new SuperMap.ThemeGridRange({
					reverseColor: false,
					rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
					//栅格分段专题图子项数组
					items: [themeGridRangeIteme1, themeGridRangeIteme2,
						themeGridRangeIteme3, themeGridRangeIteme4,
						themeGridRangeIteme5, themeGridRangeIteme6,
						themeGridRangeIteme7, themeGridRangeIteme8,
						themeGridRangeIteme9, themeGridRangeIteme10,
						themeGridRangeIteme11, themeGridRangeIteme12,
						themeGridRangeIteme13, themeGridRangeIteme14,
						themeGridRangeIteme15, themeGridRangeIteme16,
						themeGridRangeIteme17, themeGridRangeIteme18,
						themeGridRangeIteme19, themeGridRangeIteme20
					]
				});

				var themeParameters = new SuperMap.ThemeParameters({
					//制作专题图的数据集
					datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
					dataSourceNames: ["zonggui"],
					joinItems: null,
					themes: [themeGridRange]
				});

				new ol.supermap.ThemeService(urlPingyinToUrl).getThemeInfo(themeParameters, function (serviceResult) {
					var result = serviceResult.result;
					if (result && result.newResourceID) {
						themeLayer_reverseDistance = new ol.layer.Tile({
							source: new ol.source.TileSuperMapRest({
								url: urlPingyinToUrl,
								noWrap: true,
								cacheEnabled: false,
								layersID: result.newResourceID,
								tileGrid: new ol.tilegrid.TileGrid({
									extent: extent,
									resolutions: options.tileGrid.getResolutions()
								}),
								transparent: true
							})
						});
						map.addLayer(themeLayer_reverseDistance);
						//添加外围范围显示
						flyRangeLayer();
					}
				});
			}
		}
	}

	//克吕金
	function _kelvjin() {
		var options, interpolationAnalystResult;
		var extent = [440006.88, 4008876.63, 460594.99, 4023235.27];
		var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[3]);
		new ol.supermap.MapService(urlPingyinToUrl).getMapInfo(function (serviceResult) {
			;
			var mapJSONObj = serviceResult.result;
			options = ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj);
			var layer = new ol.layer.Tile({
				source: new ol.source.TileSuperMapRest(options)
			});
			interpolationAnalystProcess();
		});

		function interpolationAnalystProcess() {
			//创建点密度插值分析参数实例
			var interpolationAnalystParameters = new SuperMap.InterpolationKrigingAnalystParameters({
				//用于做插值分析的数据源中数据集的名称
				dataset: "ZG电力站点@zonggui",
				//插值分析结果数据集的名称
				outputDatasetName: "Kriging_Result",
				//插值分析结果数据源的名称
				outputDatasourceName: "zonggui",
				//结果栅格数据集存储的像素格式
				pixelFormat: SuperMap.PixelFormat.DOUBLE,
				// 属性过滤条件
				filterQueryParameter: {
					attributeFilter: ""
				},
				//插值结果栅格数据集的分辨率
				resolution: 30,
				//存储用于进行插值分析的字段名称
				zValueFieldName: "负荷",
				searchRadius: "0",
				//普通克吕金插值的类型
				type: "KRIGING",
				searchMode: "KDTREE_FIXED_COUNT",
				bounds: [440006.88, 4008876.63, 460594.99, 4023235.27]
			});
			new ol.supermap.SpatialAnalystService(spaceData).interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {
				console.log(serviceResult);
				interpolationAnalystResult = serviceResult.result;
				//用栅格专题图展示分析结果
				showAnalysisResult_ThemeGridRange();
			});

			//构造栅格专题图
			function showAnalysisResult_ThemeGridRange() {
				var color1 = new SuperMap.ServerColor(170, 240, 233),
					color2 = new SuperMap.ServerColor(176, 244, 188),
					color3 = new SuperMap.ServerColor(218, 251, 178),
					color4 = new SuperMap.ServerColor(220, 236, 145),
					color5 = new SuperMap.ServerColor(96, 198, 66),
					color6 = new SuperMap.ServerColor(20, 142, 53),
					color7 = new SuperMap.ServerColor(85, 144, 55),
					color8 = new SuperMap.ServerColor(171, 168, 38),
					color9 = new SuperMap.ServerColor(235, 165, 9),
					color10 = new SuperMap.ServerColor(203, 89, 2),
					color11 = new SuperMap.ServerColor(157, 25, 1),
					color12 = new SuperMap.ServerColor(118, 15, 3),
					color13 = new SuperMap.ServerColor(112, 32, 7),
					color14 = new SuperMap.ServerColor(106, 45, 12),
					color15 = new SuperMap.ServerColor(129, 80, 50),
					color16 = new SuperMap.ServerColor(160, 154, 146),
					color17 = new SuperMap.ServerColor(107, 47, 14),
					color18 = new SuperMap.ServerColor(125, 75, 44),
					color19 = new SuperMap.ServerColor(146, 110, 88),
					color20 = new SuperMap.ServerColor(166, 153, 146);
				var themeGridRangeIteme1 = new SuperMap.ThemeGridRangeItem({
					start: 0,
					end: 20,
					color: color1
				}),
					themeGridRangeIteme2 = new SuperMap.ThemeGridRangeItem({
						start: 20,
						end: 40,
						color: color2
					}),
					themeGridRangeIteme3 = new SuperMap.ThemeGridRangeItem({
						start: 40,
						end: 50,
						color: color3
					}),
					themeGridRangeIteme4 = new SuperMap.ThemeGridRangeItem({
						start: 50,
						end: 60,
						color: color4
					}),
					themeGridRangeIteme5 = new SuperMap.ThemeGridRangeItem({
						start: 60,
						end: 70,
						color: color5
					}),
					themeGridRangeIteme6 = new SuperMap.ThemeGridRangeItem({
						start: 70,
						end: 80,
						color: color6
					}),
					themeGridRangeIteme7 = new SuperMap.ThemeGridRangeItem({
						start: 80,
						end: 90,
						color: color7
					}),
					themeGridRangeIteme8 = new SuperMap.ThemeGridRangeItem({
						start: 90,
						end: 100,
						color: color8
					}),
					themeGridRangeIteme9 = new SuperMap.ThemeGridRangeItem({
						start: 100,
						end: 110,
						color: color9
					}),
					themeGridRangeIteme10 = new SuperMap.ThemeGridRangeItem({
						start: 110,
						end: 120,
						color: color10
					}),
					themeGridRangeIteme11 = new SuperMap.ThemeGridRangeItem({
						start: 120,
						end: 130,
						color: color11
					}),
					themeGridRangeIteme12 = new SuperMap.ThemeGridRangeItem({
						start: 130,
						end: 140,
						color: color12
					}),
					themeGridRangeIteme13 = new SuperMap.ThemeGridRangeItem({
						start: 140,
						end: 150,
						color: color13
					}),
					themeGridRangeIteme14 = new SuperMap.ThemeGridRangeItem({
						start: 150,
						end: 160,
						color: color14
					}),
					themeGridRangeIteme15 = new SuperMap.ThemeGridRangeItem({
						start: 160,
						end: 170,
						color: color15
					}),
					themeGridRangeIteme16 = new SuperMap.ThemeGridRangeItem({
						start: 170,
						end: 180,
						color: color16
					}),
					themeGridRangeIteme17 = new SuperMap.ThemeGridRangeItem({
						start: 180,
						end: 190,
						color: color17
					}),
					themeGridRangeIteme18 = new SuperMap.ThemeGridRangeItem({
						start: 190,
						end: 200,
						color: color18
					}),
					themeGridRangeIteme19 = new SuperMap.ThemeGridRangeItem({
						start: 200,
						end: 210,
						color: color19
					}),
					themeGridRangeIteme20 = new SuperMap.ThemeGridRangeItem({
						start: 210,
						end: 220,
						color: color20
					});

				var themeGridRange = new SuperMap.ThemeGridRange({
					reverseColor: false,
					rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
					//栅格分段专题图子项数组
					items: [themeGridRangeIteme1, themeGridRangeIteme2,
						themeGridRangeIteme3, themeGridRangeIteme4,
						themeGridRangeIteme5, themeGridRangeIteme6,
						themeGridRangeIteme7, themeGridRangeIteme8,
						themeGridRangeIteme9, themeGridRangeIteme10,
						themeGridRangeIteme11, themeGridRangeIteme12,
						themeGridRangeIteme13, themeGridRangeIteme14,
						themeGridRangeIteme15, themeGridRangeIteme16,
						themeGridRangeIteme17, themeGridRangeIteme18,
						themeGridRangeIteme19, themeGridRangeIteme20
					]
				});

				var themeParameters = new SuperMap.ThemeParameters({
					//制作专题图的数据集
					datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
					dataSourceNames: ["zonggui"],
					joinItems: null,
					themes: [themeGridRange]
				});

				new ol.supermap.ThemeService(urlPingyinToUrl).getThemeInfo(themeParameters, function (serviceResult) {
					console.log(serviceResult);
					var result = serviceResult.result;
					if (result && result.newResourceID) {
						themeLayer_kelvjin = new ol.layer.Tile({
							source: new ol.source.TileSuperMapRest({
								url: urlPingyinToUrl,
								noWrap: true,
								cacheEnabled: false,
								layersID: result.newResourceID,
								tileGrid: new ol.tilegrid.TileGrid({
									extent: extent,
									resolutions: options.tileGrid.getResolutions()
								}),
								transparent: true
							})
						});
						map.addLayer(themeLayer_kelvjin);
						//添加外围范围显示
						flyRangeLayer();
					}
				});
			}
		}
	}

	//离散点差值分析
	function _discretePoints() {
		var options, interpolationAnalystResult;
		var extent = [440006.88, 4008876.63, 460594.99, 4023235.27];
		var urlPingyinToUrl = getUrlPingyinUrl(urlPingyin[3]);
		new ol.supermap.MapService(urlPingyinToUrl).getMapInfo(function (serviceResult) {
			var mapJSONObj = serviceResult.result;
			options = ol.source.TileSuperMapRest.optionsFromMapJSON(urlPingyinToUrl, mapJSONObj);
			var layer = new ol.layer.Tile({
				source: new ol.source.TileSuperMapRest(options)
			});
			interpolationAnalystProcess();
		});

		function interpolationAnalystProcess() {
			//通过SQL查询的方法获取用于插值分析的geometry
			var queryBySQLParams, queryBySQLService;
			queryBySQLService = new ol.supermap.QueryService(urlPingyinToUrl);
			queryBySQLParams = new SuperMap.QueryBySQLParameters({
				queryParams: [
					new SuperMap.FilterParameter({
						name: "ZG电力站点@zonggui#1",
						attributeFilter: "SMID>0"
					})
				]
			});
			queryBySQLService.queryBySQL(queryBySQLParams, function (serviceResult) {
				var result = serviceResult.result;
				var z;
				var zMin = parseFloat(-5), zMax = parseFloat(28);
				points = [];
				if (result) {
					for (var i = 0; i < result.recordsets[0].features.features.length; i++) {
						gp = result.recordsets[0].features.features[i].geometry;
						var point = new ol.geom.Point([gp.coordinates[0], gp.coordinates[1]]);
						//每个插值点在插值过程中的权重值
						z = Math.random() * (zMax - zMin) + zMin;
						point.tag = z;
						points.push(point);
					}
				}

				//创建离散点插值分析服务实例
				interpolationAnalystService = new ol.supermap.SpatialAnalystService(spaceData);
				//创建离散点插值分析参数实例
				interpolationAnalystParameters = new SuperMap.InterpolationIDWAnalystParameters({
					// 插值分析类型,geometry类型表示对离散点插值分析,默认为“dataset”
					InterpolationAnalystType: "geometry",
					// 插值分析结果数据集的名称
					outputDatasetName: "IDWcretePoints_result",
					// 插值分析结果数据源的名称
					outputDatasourceName: "zonggui",
					// 结果栅格数据集存储的像素格式
					pixelFormat: SuperMap.PixelFormat.BIT16,
					// 用于做插值分析的离散点集合
					inputPoints: points,
					// 属性过滤条件
					//            filterQueryParameter: {
					//                attributeFilter: ""
					//            },
					// 采取定长查找参与运算点的方式
					searchMode: "KDTREE_FIXED_RADIUS",
					// 查找半径,与点数据单位相同
					searchRadius: 2000,
					//插值结果栅格数据集的分辨率
					resolution: 30,
					bounds: [440006.88, 4008876.63, 460594.99, 4023235.27]
				});
				interpolationAnalystService.interpolationAnalysis(interpolationAnalystParameters, function (serviceResult) {
					interpolationAnalystResult = serviceResult.result;
					//用栅格专题图展示分析结果
					showAnalysisResult_ThemeGridRange();
				});
			});


			//构造栅格专题图
			function showAnalysisResult_ThemeGridRange() {
				//创建专题图服务实例
				themeService = new ol.supermap.ThemeService(urlPingyinToUrl);
				var color1 = new SuperMap.ServerColor(170, 240, 233),
					color2 = new SuperMap.ServerColor(176, 244, 188),
					color3 = new SuperMap.ServerColor(218, 251, 178),
					color4 = new SuperMap.ServerColor(220, 236, 145),
					color5 = new SuperMap.ServerColor(96, 198, 66),
					color6 = new SuperMap.ServerColor(20, 142, 53),
					color7 = new SuperMap.ServerColor(85, 144, 55),
					color8 = new SuperMap.ServerColor(171, 168, 38),
					color9 = new SuperMap.ServerColor(235, 165, 9),
					color10 = new SuperMap.ServerColor(203, 89, 2),
					color11 = new SuperMap.ServerColor(157, 25, 1),
					color12 = new SuperMap.ServerColor(118, 15, 3),
					color13 = new SuperMap.ServerColor(112, 32, 7),
					color14 = new SuperMap.ServerColor(106, 45, 12),
					color15 = new SuperMap.ServerColor(129, 80, 50),
					color16 = new SuperMap.ServerColor(160, 154, 146),
					color17 = new SuperMap.ServerColor(107, 47, 14),
					color18 = new SuperMap.ServerColor(125, 75, 44),
					color19 = new SuperMap.ServerColor(146, 110, 88),
					color20 = new SuperMap.ServerColor(166, 153, 146);

				var themeGridRangeItem1 = new SuperMap.ThemeGridRangeItem({
					start: 0,
					end: 10,
					color: color1
				}),
					themeGridRangeItem2 = new SuperMap.ThemeGridRangeItem({
						start: 10,
						end: 20,
						color: color2
					}),
					themeGridRangeItem3 = new SuperMap.ThemeGridRangeItem({
						start: 20,
						end: 30,
						color: color3
					}),
					themeGridRangeItem4 = new SuperMap.ThemeGridRangeItem({
						start: 30,
						end: 40,
						color: color4
					}),
					themeGridRangeItem5 = new SuperMap.ThemeGridRangeItem({
						start: 40,
						end: 50,
						color: color5
					}),
					themeGridRangeItem6 = new SuperMap.ThemeGridRangeItem({
						start: 50,
						end: 60,
						color: color6
					}),
					themeGridRangeItem7 = new SuperMap.ThemeGridRangeItem({
						start: 60,
						end: 70,
						color: color7
					}),
					themeGridRangeItem8 = new SuperMap.ThemeGridRangeItem({
						start: 70,
						end: 80,
						color: color8
					}),
					themeGridRangeItem9 = new SuperMap.ThemeGridRangeItem({
						start: 80,
						end: 90,
						color: color9
					}),
					themeGridRangeItem10 = new SuperMap.ThemeGridRangeItem({
						start: 90,
						end: 100,
						color: color10
					}),
					themeGridRangeItem11 = new SuperMap.ThemeGridRangeItem({
						start: 100,
						end: 110,
						color: color11
					}),
					themeGridRangeItem12 = new SuperMap.ThemeGridRangeItem({
						start: 110,
						end: 120,
						color: color12
					}),
					themeGridRangeItem13 = new SuperMap.ThemeGridRangeItem({
						start: 120,
						end: 130,
						color: color13
					}),
					themeGridRangeItem14 = new SuperMap.ThemeGridRangeItem({
						start: 130,
						end: 140,
						color: color14
					}),
					themeGridRangeItem15 = new SuperMap.ThemeGridRangeItem({
						start: 140,
						end: 150,
						color: color15
					}),
					themeGridRangeItem16 = new SuperMap.ThemeGridRangeItem({
						start: 150,
						end: 160,
						color: color16
					}),
					themeGridRangeItem17 = new SuperMap.ThemeGridRangeItem({
						start: 160,
						end: 170,
						color: color17
					}),
					themeGridRangeItem18 = new SuperMap.ThemeGridRangeItem({
						start: 170,
						end: 180,
						color: color18
					}),
					themeGridRangeItem19 = new SuperMap.ThemeGridRangeItem({
						start: 180,
						end: 200,
						color: color19
					}),
					themeGridRangeItem20 = new SuperMap.ThemeGridRangeItem({
						start: 200,
						end: 220,
						color: color20
					});

				themeGridRange = new SuperMap.ThemeGridRange({
					reverseColor: false,
					rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
					//栅格分段专题图子项数组
					items: [themeGridRangeItem1, themeGridRangeItem2,
						themeGridRangeItem3, themeGridRangeItem4,
						themeGridRangeItem5, themeGridRangeItem6,
						themeGridRangeItem7, themeGridRangeItem8,
						themeGridRangeItem9, themeGridRangeItem10,
						themeGridRangeItem11, themeGridRangeItem12,
						themeGridRangeItem13, themeGridRangeItem14,
						themeGridRangeItem15, themeGridRangeItem16,
						themeGridRangeItem17, themeGridRangeItem18,
						themeGridRangeItem19, themeGridRangeItem20
					]
				});

				themeParameters = new SuperMap.ThemeParameters({
					//制作专题图的数据集
					datasetNames: [interpolationAnalystResult.dataset.split('@')[0]],
					dataSourceNames: ["zonggui"],
					joinItems: null,
					themes: [themeGridRange]
				});

				themeService.getThemeInfo(themeParameters, function (serviceResult) {
					var result = serviceResult.result;
					if (result && result.newResourceID) {
						themeLayer_discretePoints = new ol.layer.Tile({
							source: new ol.source.TileSuperMapRest({
								url: urlPingyinToUrl,
								noWrap: true,
								cacheEnabled: false,
								transparent: true,
								layersID: result.newResourceID,
								tileGrid: new ol.tilegrid.TileGrid({
									extent: extent,
									resolutions: options.tileGrid.getResolutions()
								}),
							})
						});
						map.addLayer(themeLayer_discretePoints);
						//添加外围范围显示
						flyRangeLayer();
					}
				});
			}
		}
	}


	//点密度；反距离；克吕金；离散点所需  [添加外围图层]
	function flyRangeLayer(){
		//var RangeLayerUrl = "http://172.29.1.26:8090/iserver/services/map-py016/rest/maps/ZG用地规划/layers/ZG规划范围@zonggui.1@@LayerGroup.1@@ZG用地规划.html";
		/*
		RangeLayer = new ol.layer.Tile({
			source: new ol.source.TileSuperMapRest({
				url: RangeLayerUrl,
				noWrap: true,
				cacheEnabled: false,
				transparent: true
			})
		});
		map.addLayer(RangeLayer);
		*/
	}





	//百度地图
	var baiduMapMark;
	function _baiduMap(baiduMapMark1) {
		baiduMapMark=baiduMapMark1;

		if ($(baiduMapMark).is(':checked')) {
			FunctionAddEvent.layerBaidu = true;
			//移除当前已有图层
			if (layerTianDi) {
				map.removeLayer(layerTianDi);
				map.removeLayer(layerTianDi2);
			}
			//增加百度地图
			layerBaidu = new ol.layer.Tile({
				source: new ol.source.BaiduMap(),
			});
			map.addLayer(layerBaidu);
			$('#dict').hide();
			view.animate({
				center: [12957935.9338, 4304565.3854],
				duration: 1000,
				zoom: 13
			});
		} else {
			$('#dict').show();
			view.animate({
				center: [451343.84 , 4017036.9],
				zoom: 14
			});
			map.removeLayer(layerBaidu);
		}
	}

	//天地图
	var tiandiMapMark;
	function _tiandiMap(tiandiMapMark1) {
		tiandiMapMark=tiandiMapMark1;

		if ($(tiandiMapMark).is(':checked')) {
			FunctionAddEvent.layerTianDi = true;
			//移除当前已有图层
			if (layerBaidu) {
				map.removeLayer(layerBaidu);
			}
			layerTianDi = new ol.layer.Tile({
				source: new ol.source.Tianditu({
					layerType: 'ter',
					projection: "EPSG:4326"
				})
			});
			layerTianDi2 = new ol.layer.Tile({
				source: new ol.source.Tianditu({
					layerType: 'ter',
					isLabel: true,
					projection: "EPSG:4326"
				})
			});
			map.addLayer(layerTianDi);
			map.addLayer(layerTianDi2);
			$('#dict').hide();
			view.animate({
				center: [12967935.9338, 4335575.3854],
				zoom: 13,
				projection: "EPSG:4326"
			});
		} else {
			$('#dict').show();
			view.animate({
				center: [451343.84 , 4017036.9],
				zoom: 14
			});
			map.removeLayer(layerTianDi);
			map.removeLayer(layerTianDi2);
		}
	}






	//地图打印   [由于跨域，须在发布服务器中运行使用]
	function _printMap(id) {
		var broz = SuperMap.Browser.name;
		if (broz == 'msie' && parseInt(SuperMap.Browser.version) < 9) {
			alert("ie9版本以下部分打印功能不支持");
			return;
		}
		var printWindow = window.open("");
		var strInnerHTML = document.getElementById("mapDiv").innerHTML;
		var strHeader = "<!DOCTYPE html><html><head><META HTTP-EQUIV='pragma' CONTENT='no-cache'><META HTTP-EQUIV='Cache-Control' CONTENT='no-cache, must-revalidate'><META HTTP-EQUIV='expires' CONTENT='Wed, 26 Feb 1997 08:21:57 GMT'><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' /><meta name='apple-mobile-web-app-capable' content='yes' /><title>地图打印</title>";
		var strCSS = "<link href='" + publicurl + "/OpenLayers/css/sm.css' rel='stylesheet' /><link href='" + publicurl + "/OpenLayers/css/sm-responsive.css' rel='stylesheet' /><link href='" + publicurl + "/OpenLayers/theme/default/style.css' rel='stylesheet'><link href='" + publicurl + "/OpenLayers/css/sm-doc.css' rel='stylesheet' />";
		var strScript = "<script src='" + publicurl + "/OpenLayers/js/jquery.js'><\/script><script type = 'text/javascript'>" + "\n" + "function printDiv(){$('.newuiPrint').css({'display':'none'});window.print();$('.newuiPrint').css({'display':'block'});}<\/script>";
		var strBody = "</head><body><div class='print-header'><div class='superD'><h3>地图</h3></div><div id='" + id + "' >" + strInnerHTML + "</div><div id='superft'><div class='printClose'>" + "<span class='newuiPrint' onclick = 'printDiv()'></span></div></div></div></body></html>";

		var strHTML = strHeader + strCSS + strScript + strBody;
		printWindow.document.write(strHTML);
		printWindow.document.close();

		function onloadHTML() {
			var strDOM = printWindow.document.getElementById(id).children[0].children;
			for (var i = 0, length = strDOM.length; i < length; i++) {
				var idStr = strDOM[i].id;
				if (idStr.indexOf("SuperMap.Control.ScaleLine") == -1 && idStr.indexOf("SuperMap.Map") == -1) {
					strCss = strDOM[i].style.cssText;
					strCss = strCss + "display: none;";
					strDOM[i].style.cssText = strCss;
				}
			}
			var canvasPrint = printWindow.document.getElementsByTagName("canvas");
			var canvasMap = document.getElementsByTagName("canvas");
			for (var i = 0, length = canvasPrint.length; i < length; i++) {
				pasteCanvas(canvasMap[i], canvasPrint[i]);
			}
		}
		if (broz == 'firefox') {
			printWindow.onload = onloadHTML;
		} else if (broz == 'safari' || broz == 'chrome' || broz == 'msie') {
			window.setTimeout(onloadHTML, 50);
		}
		//如果涉及到Canvas的图层打印，需要将范例发布出来运行，否则会产生跨域的问题
		function pasteCanvas(sCanvas/*source*/, dCanvas/*destination*/) {
			var w = sCanvas.width,
				h = sCanvas.height;
			dCanvas.width = w;
			dCanvas.height = h;
			var viewerImageSrc = sCanvas.toDataURL("image/png");
			var viewerImage = new Image();
			viewerImage.src = viewerImageSrc;
			var dContext = dCanvas.getContext("2d");
			dContext.drawImage(viewerImage, 0, 0, w, h);
		}
	}

	//地图截图   [由于跨域，须在发布服务器中运行使用]
	function _cutMap() {
		map.once('postcompose', function(event) {
          var canvas = event.context.canvas;
          if (navigator.msSaveBlob) {
            navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
          } else {
            canvas.toBlob(function(blob) {
              saveAs(blob, 'map.png');
            });
          }
        });
        map.renderSync();
	}

    return {
    	layerTree:_layerTree,
    	testalert:_testalert,
    	method1:_method1,
  	 	educeInfo:_educeInfo,
    	//two : _two,
    	windowCurtains : _WindowCurtains,
		autodivheight:_autodivheight,
		distance: _distance,
		area:_area,
		plotting:_plotting,
		clear:_clear,
		geometric:_geometric,
		polygonalSelection:_polygonalSelection,
		infoHot:_infoHot,
		vectorInfo:_vectorInfo,
		landUsed:_landUsed,
		landUsedRank:_landUsedRank,
		labelTheme:_labelTheme,
		multipleChoice:_multipleChoice,
		getLayer:_getLayer,
		vectorControl:_vectorControl,
		sqlselect:_sqlselect,
		dotDensity: _dotDensity,
		baiduMap: _baiduMap,
		tiandiMap: _tiandiMap,
		printMap: _printMap,
		cutMap: _cutMap,
		surfaceAnalysis: _surfaceAnalysis,
		bufferAnalyse: _bufferAnalyse,
		reverseDistance: _reverseDistance,
		kelvjin: _kelvjin,
		discretePoints: _discretePoints
	};

});

